Browse Source

Perform onException delegation outside of connection monitor

Issue: SPR-15738
(cherry picked from commit 6d55b3a)
pull/1479/head
Juergen Hoeller 9 years ago
parent
commit
a9a4d7cf78
  1. 14
      spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2017 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.
@ -666,12 +666,14 @@ public class SingleConnectionFactory implements ConnectionFactory, QueueConnecti @@ -666,12 +666,14 @@ public class SingleConnectionFactory implements ConnectionFactory, QueueConnecti
@Override
public void onException(JMSException ex) {
// Iterate over temporary copy in order to avoid ConcurrentModificationException,
// since listener invocations may in turn trigger registration of listeners...
Set<ExceptionListener> copy;
synchronized (connectionMonitor) {
// 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);
}
copy = new LinkedHashSet<ExceptionListener>(this.delegates);
}
for (ExceptionListener listener : copy) {
listener.onException(ex);
}
}
}

Loading…
Cancel
Save