Perform onException delegation outside of connection monitor

Issue: SPR-15738
This commit is contained in:
Juergen Hoeller 2017-07-07 20:44:09 +02:00
parent 7d747f9645
commit 6d55b3a592
1 changed files with 7 additions and 5 deletions

View File

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