Skip to content

Commit 6d55b3a

Browse files
committed
Perform onException delegation outside of connection monitor
Issue: SPR-15738
1 parent 7d747f9 commit 6d55b3a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -706,12 +706,14 @@ private class AggregatedExceptionListener implements ExceptionListener {
706706

707707
@Override
708708
public void onException(JMSException ex) {
709+
// Iterate over temporary copy in order to avoid ConcurrentModificationException,
710+
// since listener invocations may in turn trigger registration of listeners...
711+
Set<ExceptionListener> copy;
709712
synchronized (connectionMonitor) {
710-
// Iterate over temporary copy in order to avoid ConcurrentModificationException,
711-
// since listener invocations may in turn trigger registration of listeners...
712-
for (ExceptionListener listener : new LinkedHashSet<>(this.delegates)) {
713-
listener.onException(ex);
714-
}
713+
copy = new LinkedHashSet<>(this.delegates);
714+
}
715+
for (ExceptionListener listener : copy) {
716+
listener.onException(ex);
715717
}
716718
}
717719
}

0 commit comments

Comments
 (0)