You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2015/02/26 18:08:31 UTC

qpid-jms git commit: Update the remotely closed handler to run in the connection executor so that the provider thread gets to go back to work.

Repository: qpid-jms
Updated Branches:
  refs/heads/master f7d3a4609 -> 76093b653


Update the remotely closed handler to run in the connection executor so
that the provider thread gets to go back to work. 

Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/76093b65
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/76093b65
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/76093b65

Branch: refs/heads/master
Commit: 76093b6538ef740ff65649f986b231b843e6ff9d
Parents: f7d3a46
Author: Timothy Bish <ta...@gmail.com>
Authored: Thu Feb 26 11:46:49 2015 -0500
Committer: Timothy Bish <ta...@gmail.com>
Committed: Thu Feb 26 11:46:49 2015 -0500

----------------------------------------------------------------------
 .../java/org/apache/qpid/jms/JmsConnection.java | 38 ++++++++++++--------
 1 file changed, 24 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/76093b65/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnection.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnection.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnection.java
index 2aa1b1e..5806745 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnection.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnection.java
@@ -1098,23 +1098,33 @@ public class JmsConnection implements Connection, TopicConnection, QueueConnecti
     }
 
     @Override
-    public void onResourceRemotelyClosed(JmsResource resource, Exception cause) {
+    public void onResourceRemotelyClosed(final JmsResource resource, final Exception cause) {
         // Closure of the Connection itself is notified via onConnectionFailure
 
-        if (resource instanceof JmsSessionInfo) {
-            JmsSession s = sessions.get(resource);
-            if (s != null) {
-                try {
-                    // TODO: pass the exception?
-                    s.shutdown();
-                } catch (JMSException e) {
-                    LOG.warn("Cause exception while notifying session of remote close: {}", cause, cause);
-                }
+        // Run on the connection executor to free the provider to go do more work and avoid
+        // any chance of a deadlock if the code ever looped back to the provider.
+        if (!closing.get() && !closed.get()) {
+            executor.execute(new Runnable() {
 
-                // TODO: exception listener?
-            }
-        } else {
-            LOG.info("A JMS resource has been remotely closed: {}", resource);
+                @Override
+                public void run() {
+                    if (resource instanceof JmsSessionInfo) {
+                        JmsSession s = sessions.get(resource);
+                        if (s != null) {
+                            try {
+                                // TODO: pass the exception?
+                                s.shutdown();
+                            } catch (JMSException e) {
+                                LOG.warn("Cause exception while notifying session of remote close: {}", cause, cause);
+                            }
+
+                            // TODO: exception listener?
+                        }
+                    } else {
+                        LOG.info("A JMS resource has been remotely closed: {}", resource);
+                    }
+                }
+            });
         }
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org