Added synchronized when iterating over SynchronizedList as per Java specifications

This commit is contained in:
emopers 2015-11-24 05:46:37 -06:00 committed by Wajihulhassan
parent d730e35f9d
commit 948e9809ca
1 changed files with 10 additions and 7 deletions

View File

@ -858,14 +858,17 @@ public class TransportConnection implements Connection, Task, CommandVisitor {
}
}
// Cascade the connection stop to temp destinations.
for (Iterator<DestinationInfo> 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<DestinationInfo> tempDestinations = cs.getTempDestinations();
synchronized (tempDestinations) {
for (Iterator<DestinationInfo> 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());