diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java b/activemq-core/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java index 733ff98da0..b1c595c4a0 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/region/AbstractRegion.java @@ -262,13 +262,18 @@ public abstract class AbstractRegion implements Region { // so everything after this point would be leaked. // Add the subscription to all the matching queues. - + // But copy the matches first - to prevent deadlocks + ListaddList = new ArrayList(); synchronized(destinationsMutex) { for (Iterator iter = destinationMap.get(info.getDestination()).iterator(); iter.hasNext();) { Destination dest = (Destination)iter.next(); - dest.addSubscription(context, sub); + addList.add(dest); } } + + for (Destination dest:addList) { + dest.addSubscription(context, sub); + } if (info.isBrowser()) { ((QueueBrowserSubscription)sub).destinationsAdded();