Skip to content

Commit 1ed1167

Browse files
committed
Avoid ConcurrentModificationException in SingleConnectionFactory's AggregatedExceptionListener
Issue: SPR-13421
1 parent 2caaa81 commit 1ed1167

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 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.
@@ -667,7 +667,9 @@ private class AggregatedExceptionListener implements ExceptionListener {
667667
@Override
668668
public void onException(JMSException ex) {
669669
synchronized (connectionMonitor) {
670-
for (ExceptionListener listener : this.delegates) {
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)) {
671673
listener.onException(ex);
672674
}
673675
}

0 commit comments

Comments
 (0)