From b5288982ca11475f177793b5c4b3abdc21154b6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Andr=C3=A9=20Pearce?= Date: Thu, 8 Feb 2018 23:51:04 +0000 Subject: [PATCH] ARTEMIS-853 - Support for exclusive consumers Fix coverity findings. --- .../wireformat/CreateQueueMessage_V2.java | 10 ++++++++-- .../CreateSharedQueueMessage_V2.java | 20 +++++++++++++++---- ...SessionBindingQueryResponseMessage_V4.java | 10 ++++++++-- .../SessionQueueQueryResponseMessage_V3.java | 10 ++++++++-- .../artemis/jms/client/ActiveMQSession.java | 2 +- 5 files changed, 41 insertions(+), 11 deletions(-) diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateQueueMessage_V2.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateQueueMessage_V2.java index 4ffeb5ca8436..baccc367c468 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateQueueMessage_V2.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateQueueMessage_V2.java @@ -182,9 +182,15 @@ public boolean equals(Object obj) { return false; if (purgeOnNoConsumers != other.purgeOnNoConsumers) return false; - if (exclusive != other.exclusive) + if (exclusive == null) { + if (other.exclusive != null) + return false; + } else if (!exclusive.equals(other.exclusive)) return false; - if (lastValue != other.lastValue) + if (lastValue == null) { + if (other.lastValue != null) + return false; + } else if (!lastValue.equals(other.lastValue)) return false; if (routingType == null) { if (other.routingType != null) diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateSharedQueueMessage_V2.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateSharedQueueMessage_V2.java index 87630434fbf5..d220915581ac 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateSharedQueueMessage_V2.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/CreateSharedQueueMessage_V2.java @@ -192,13 +192,25 @@ public boolean equals(Object obj) { return false; if (requiresResponse != other.requiresResponse) return false; - if (maxConsumers != other.maxConsumers) + if (maxConsumers == null) { + if (other.maxConsumers != null) + return false; + } else if (!maxConsumers.equals(other.maxConsumers)) return false; - if (purgeOnNoConsumers != other.purgeOnNoConsumers) + if (purgeOnNoConsumers == null) { + if (other.purgeOnNoConsumers != null) + return false; + } else if (!purgeOnNoConsumers.equals(other.purgeOnNoConsumers)) return false; - if (exclusive != other.exclusive) + if (exclusive == null) { + if (other.exclusive != null) + return false; + } else if (!exclusive.equals(other.exclusive)) return false; - if (lastValue != other.lastValue) + if (lastValue == null) { + if (other.lastValue != null) + return false; + } else if (!lastValue.equals(other.lastValue)) return false; return true; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionBindingQueryResponseMessage_V4.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionBindingQueryResponseMessage_V4.java index 0d08d9907834..ca0e9f79f4eb 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionBindingQueryResponseMessage_V4.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionBindingQueryResponseMessage_V4.java @@ -140,9 +140,15 @@ public boolean equals(Object obj) { return false; if (defaultMaxConsumers != other.defaultMaxConsumers) return false; - if (defaultExclusive != other.defaultExclusive) + if (defaultExclusive == null) { + if (other.defaultExclusive != null) + return false; + } else if (!defaultExclusive.equals(other.defaultExclusive)) return false; - if (defaultLastValue != other.defaultLastValue) + if (defaultLastValue == null) { + if (other.defaultLastValue != null) + return false; + } else if (!defaultLastValue.equals(other.defaultLastValue)) return false; return true; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionQueueQueryResponseMessage_V3.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionQueueQueryResponseMessage_V3.java index 12f2a7b962ef..b982744e0490 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionQueueQueryResponseMessage_V3.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionQueueQueryResponseMessage_V3.java @@ -216,9 +216,15 @@ public boolean equals(Object obj) { return false; if (purgeOnNoConsumers != other.purgeOnNoConsumers) return false; - if (exclusive != other.exclusive) + if (exclusive == null) { + if (other.exclusive != null) + return false; + } else if (!exclusive.equals(other.exclusive)) return false; - if (lastValue != other.lastValue) + if (lastValue == null) { + if (other.lastValue != null) + return false; + } else if (!lastValue.equals(other.lastValue)) return false; if (routingType == null) { if (other.routingType != null) diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java index a0ccfcca8d1a..5f292113191c 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java @@ -1173,7 +1173,7 @@ private void createTemporaryQueue(ActiveMQDestination destination, RoutingType r } } - private void createSharedQueue(ActiveMQDestination destination, RoutingType routingType, SimpleString queueName, SimpleString filter, boolean durable, int maxConsumers, boolean purgeOnNoConsumers, Boolean exclusive, Boolean lastValue) throws ActiveMQException { + private void createSharedQueue(ActiveMQDestination destination, RoutingType routingType, SimpleString queueName, SimpleString filter, boolean durable, Integer maxConsumers, Boolean purgeOnNoConsumers, Boolean exclusive, Boolean lastValue) throws ActiveMQException { QueueAttributes queueAttributes = destination.getQueueAttributes(); if (queueAttributes == null) { session.createSharedQueue(destination.getSimpleAddress(), routingType, queueName, filter, durable, maxConsumers, purgeOnNoConsumers, exclusive, lastValue);