diff --git a/spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java b/spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java index c3cf003f20b..05c28ae6efb 100644 --- a/spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java +++ b/spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java @@ -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(this.delegates)) { listener.onException(ex); } }