Avoid ConcurrentModificationException in SingleConnectionFactory's AggregatedExceptionListener
Issue: SPR-13421
This commit is contained in:
parent
2caaa81afa
commit
1ed1167153
|
@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -667,7 +667,9 @@ public class SingleConnectionFactory implements ConnectionFactory, QueueConnecti
|
|||
@Override
|
||||
public void onException(JMSException ex) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue