release the connection even if broker communication fails

(cherry picked from commit 934f3cea7e)
This commit is contained in:
Romain Manni-Bucau 2015-11-19 07:48:56 -08:00 committed by Christopher L. Shannon (cshannon)
parent 81ef5efdc7
commit d9a79d172b
1 changed files with 26 additions and 24 deletions

View File

@ -678,6 +678,7 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
this.activeTempDestinations.clear(); this.activeTempDestinations.clear();
try {
if (isConnectionInfoSentToBroker) { if (isConnectionInfoSentToBroker) {
// If we announced ourselves to the broker.. Try to let the broker // If we announced ourselves to the broker.. Try to let the broker
// know that the connection is being shutdown. // know that the connection is being shutdown.
@ -694,7 +695,7 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
} }
doAsyncSendPacket(new ShutdownInfo()); doAsyncSendPacket(new ShutdownInfo());
} }
} finally { // release anyway even if previous communication fails
started.set(false); started.set(false);
// TODO if we move the TaskRunnerFactory to the connection // TODO if we move the TaskRunnerFactory to the connection
@ -708,6 +709,7 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
closing.set(false); closing.set(false);
} }
} }
}
} finally { } finally {
try { try {
if (executor != null) { if (executor != null) {