Avoid ConcurrentModificationException in SingleConnectionFactory's AggregatedExceptionListener
Issue: SPR-13421
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2014 the original author or authors.
|
* Copyright 2002-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -667,7 +667,9 @@ public class SingleConnectionFactory implements ConnectionFactory, QueueConnecti
|
|||||||
@Override
|
@Override
|
||||||
public void onException(JMSException ex) {
|
public void onException(JMSException ex) {
|
||||||
synchronized (connectionMonitor) {
|
synchronized (connectionMonitor) {
|
||||||
for (ExceptionListener listener : this.delegates) {
|
// Iterate over temporary copy in order to avoid ConcurrentModificationException,
|
||||||
|
// since listener invocations may in turn trigger registration of listeners...
|
||||||
|
for (ExceptionListener listener : new LinkedHashSet<ExceptionListener>(this.delegates)) {
|
||||||
listener.onException(ex);
|
listener.onException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user