Skip to content

Commit a9a4d7c

Browse files
committed
Perform onException delegation outside of connection monitor
Issue: SPR-15738 (cherry picked from commit 6d55b3a)
1 parent 17382ae commit a9a4d7c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -666,12 +666,14 @@ private class AggregatedExceptionListener implements ExceptionListener {
666666

667667
@Override
668668
public void onException(JMSException ex) {
669+
// Iterate over temporary copy in order to avoid ConcurrentModificationException,
670+
// since listener invocations may in turn trigger registration of listeners...
671+
Set<ExceptionListener> copy;
669672
synchronized (connectionMonitor) {
670-
// Iterate over temporary copy in order to avoid ConcurrentModificationException,
671-
// since listener invocations may in turn trigger registration of listeners...
672-
for (ExceptionListener listener : new LinkedHashSet<ExceptionListener>(this.delegates)) {
673-
listener.onException(ex);
674-
}
673+
copy = new LinkedHashSet<ExceptionListener>(this.delegates);
674+
}
675+
for (ExceptionListener listener : copy) {
676+
listener.onException(ex);
675677
}
676678
}
677679
}

0 commit comments

Comments
 (0)