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 97de9214a6..65f2d7b555 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 audit = new HashMap(); + private final ConcurrentMap audit = new ConcurrentHashMap(); 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 {