Repository: activemq
Updated Branches:
  refs/heads/activemq-5.12.x 81ef5efdc -> d9a79d172


release the connection even if broker communication fails

(cherry picked from commit 934f3cea7effdff3b43ddabc9d0f03535fa44e5f)


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/d9a79d17
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/d9a79d17
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/d9a79d17

Branch: refs/heads/activemq-5.12.x
Commit: d9a79d172be3646ce64349fe4a0454df9e382424
Parents: 81ef5ef
Author: Romain Manni-Bucau <rmann...@gmail.com>
Authored: Thu Nov 19 07:48:56 2015 -0800
Committer: Christopher L. Shannon (cshannon) <christopher.l.shan...@gmail.com>
Committed: Fri Nov 20 13:37:03 2015 +0000

----------------------------------------------------------------------
 .../org/apache/activemq/ActiveMQConnection.java | 52 ++++++++++----------
 1 file changed, 27 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/d9a79d17/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java
----------------------------------------------------------------------
diff --git 
a/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java 
b/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java
index 50a64d8..aecece1 100755
--- a/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java
+++ b/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java
@@ -678,34 +678,36 @@ public class ActiveMQConnection implements Connection, 
TopicConnection, QueueCon
 
                     this.activeTempDestinations.clear();
 
-                    if (isConnectionInfoSentToBroker) {
-                        // If we announced ourselves to the broker.. Try to 
let the broker
-                        // know that the connection is being shutdown.
-                        RemoveInfo removeCommand = info.createRemoveCommand();
-                        
removeCommand.setLastDeliveredSequenceId(lastDeliveredSequenceId);
-                        try {
-                            doSyncSendPacket(removeCommand, closeTimeout);
-                        } catch (JMSException e) {
-                            if (e.getCause() instanceof 
RequestTimedOutIOException) {
-                                // expected
-                            } else {
-                                throw e;
+                    try {
+                        if (isConnectionInfoSentToBroker) {
+                            // If we announced ourselves to the broker.. Try 
to let the broker
+                            // know that the connection is being shutdown.
+                            RemoveInfo removeCommand = 
info.createRemoveCommand();
+                            
removeCommand.setLastDeliveredSequenceId(lastDeliveredSequenceId);
+                            try {
+                                doSyncSendPacket(removeCommand, closeTimeout);
+                            } catch (JMSException e) {
+                                if (e.getCause() instanceof 
RequestTimedOutIOException) {
+                                    // expected
+                                } else {
+                                    throw e;
+                                }
                             }
+                            doAsyncSendPacket(new ShutdownInfo());
                         }
-                        doAsyncSendPacket(new ShutdownInfo());
-                    }
-
-                    started.set(false);
-
-                    // TODO if we move the TaskRunnerFactory to the connection
-                    // factory
-                    // then we may need to call
-                    // factory.onConnectionClose(this);
-                    if (sessionTaskRunner != null) {
-                        sessionTaskRunner.shutdown();
+                    } finally { // release anyway even if previous 
communication fails
+                        started.set(false);
+
+                        // TODO if we move the TaskRunnerFactory to the 
connection
+                        // factory
+                        // then we may need to call
+                        // factory.onConnectionClose(this);
+                        if (sessionTaskRunner != null) {
+                            sessionTaskRunner.shutdown();
+                        }
+                        closed.set(true);
+                        closing.set(false);
                     }
-                    closed.set(true);
-                    closing.set(false);
                 }
             }
         } finally {

Reply via email to