From 948e9809caf238991c5216567e135b080f81676d Mon Sep 17 00:00:00 2001 From: emopers Date: Tue, 24 Nov 2015 05:46:37 -0600 Subject: [PATCH] Added synchronized when iterating over SynchronizedList as per Java specifications --- .../activemq/broker/TransportConnection.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnection.java b/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnection.java index a9d36b5da3..cbb6ffe40a 100755 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnection.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnection.java @@ -858,14 +858,17 @@ public class TransportConnection implements Connection, Task, CommandVisitor { } } // Cascade the connection stop to temp destinations. - for (Iterator iter = cs.getTempDestinations().iterator(); iter.hasNext(); ) { - DestinationInfo di = iter.next(); - try { - broker.removeDestination(cs.getContext(), di.getDestination(), 0); - } catch (Throwable e) { - SERVICELOG.warn("Failed to remove tmp destination {}", di.getDestination(), e); + List tempDestinations = cs.getTempDestinations(); + synchronized (tempDestinations) { + for (Iterator iter = tempDestinations.iterator(); iter.hasNext(); ) { + DestinationInfo di = iter.next(); + try { + broker.removeDestination(cs.getContext(), di.getDestination(), 0); + } catch (Throwable e) { + SERVICELOG.warn("Failed to remove tmp destination {}", di.getDestination(), e); + } + iter.remove(); } - iter.remove(); } try { broker.removeConnection(cs.getContext(), cs.getInfo(), transportException.get());