Repository: activemq Updated Branches: refs/heads/activemq-5.13.x db87a051c -> 819e51213
https://issues.apache.org/jira/browse/AMQ-6062 Updated QueueBrowserSubscription to use a ConcurrentMap to avoid a potential race condition when multiple queue browsers browse multiple queues. (cherry picked from commit d346a765e3064a951c5d55119b80b8432a45bcb6) Project: http://git-wip-us.apache.org/repos/asf/activemq/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/819e5121 Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/819e5121 Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/819e5121 Branch: refs/heads/activemq-5.13.x Commit: 819e512138f55d70197949a4fae208a81ea86502 Parents: db87a05 Author: Christopher L. Shannon (cshannon) <[email protected]> Authored: Wed Dec 2 15:51:55 2015 +0000 Committer: Christopher L. Shannon (cshannon) <[email protected]> Committed: Wed Dec 2 15:53:59 2015 +0000 ---------------------------------------------------------------------- .../broker/region/QueueBrowserSubscription.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq/blob/819e5121/activemq-broker/src/main/java/org/apache/activemq/broker/region/QueueBrowserSubscription.java ---------------------------------------------------------------------- diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/QueueBrowserSubscription.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/QueueBrowserSubscription.java index 97de921..65f2d7b 100755 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/QueueBrowserSubscription.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/QueueBrowserSubscription.java @@ -18,9 +18,9 @@ package org.apache.activemq.broker.region; import java.io.IOException; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import javax.jms.JMSException; @@ -42,7 +42,7 @@ public class QueueBrowserSubscription extends QueueSubscription { boolean browseDone; boolean destinationsAdded; - private final Map<MessageId, Object> audit = new HashMap<MessageId, Object>(); + private final ConcurrentMap<MessageId, Object> audit = new ConcurrentHashMap<MessageId, Object>(); private long maxMessages; public QueueBrowserSubscription(Broker broker, SystemUsage usageManager, ConnectionContext context, ConsumerInfo info) throws JMSException { @@ -67,13 +67,7 @@ public class QueueBrowserSubscription extends QueueSubscription { } public boolean isDuplicate(MessageId messageId) { - - if (!audit.containsKey(messageId)) { - audit.put(messageId, Boolean.TRUE); - return false; - } - - return true; + return audit.putIfAbsent(messageId, Boolean.TRUE) != null; } private void checkDone() throws Exception {
