Browse Source

Perform onException delegation outside of connection monitor

Issue: SPR-15738
pull/1472/head
Juergen Hoeller 9 years ago
parent
commit
6d55b3a592
  1. 12
      spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java

12
spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java

@ -706,12 +706,14 @@ public class SingleConnectionFactory implements ConnectionFactory, QueueConnecti @@ -706,12 +706,14 @@ public class SingleConnectionFactory implements ConnectionFactory, QueueConnecti
@Override
public void onException(JMSException ex) {
// Iterate over temporary copy in order to avoid ConcurrentModificationException,
// since listener invocations may in turn trigger registration of listeners...
Set<ExceptionListener> copy;
synchronized (connectionMonitor) {
// Iterate over temporary copy in order to avoid ConcurrentModificationException,
// since listener invocations may in turn trigger registration of listeners...
for (ExceptionListener listener : new LinkedHashSet<>(this.delegates)) {
listener.onException(ex);
}
copy = new LinkedHashSet<>(this.delegates);
}
for (ExceptionListener listener : copy) {
listener.onException(ex);
}
}
}

Loading…
Cancel
Save