From 874b973366824fba1ae502b10c9a5b66c11e4779 Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Thu, 25 Apr 2013 15:04:36 +0000 Subject: QPID-4714 Moved _delegate.closeConnection method inside a finally block to ensure the TCP connection is closed in case an exception is thrown from any of the methods above. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1475810 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/qpid/client/AMQConnection.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java index 9612417266..4e885258b9 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java @@ -909,8 +909,6 @@ public class AMQConnection extends Closeable implements Connection, QueueConnect // adjust timeout timeout = adjustTimeout(timeout, startCloseTime); - _delegate.closeConnection(timeout); - //If the taskpool hasn't shutdown by now then give it shutdownNow. // This will interupt any running tasks. if (!_taskPool.isTerminated()) @@ -922,7 +920,7 @@ public class AMQConnection extends Closeable implements Connection, QueueConnect } } } - catch (AMQException e) + catch (JMSException e) { _logger.error("error:", e); JMSException jmse = new JMSException("Error closing connection: " + e); @@ -930,6 +928,17 @@ public class AMQConnection extends Closeable implements Connection, QueueConnect jmse.initCause(e); throw jmse; } + finally + { + try + { + _delegate.closeConnection(timeout); + } + catch (Exception e) + { + _logger.warn("Error closing underlying protocol connection", e); + } + } } } } -- cgit v1.2.1