From 1987cfa2347cba9299eaed98a1e6b39c9ab7f45b Mon Sep 17 00:00:00 2001 From: Robert Davies Date: Sat, 15 Mar 2008 18:59:49 +0000 Subject: [PATCH] Only unlock a service lock if we managed to lock it git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@637454 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/activemq/broker/TransportConnection.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java b/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java index 977e30a2d4..e832acbef3 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java @@ -889,10 +889,11 @@ public class TransportConnection implements Connection, Task, CommandVisitor { new Thread("ActiveMQ Transport Stopper: "+ transport.getRemoteAddress()) { @Override public void run() { + boolean locked = false; // make sure we are not servicing client requests while we are shutting down. try { //we could be waiting a long time if the network has gone - so only wait 1 second - serviceLock.writeLock().tryLock(1,TimeUnit.SECONDS); + locked = serviceLock.writeLock().tryLock(1,TimeUnit.SECONDS); } catch (InterruptedException e) { LOG.debug("Try get writeLock interrupted ",e); } @@ -903,7 +904,9 @@ public class TransportConnection implements Connection, Task, CommandVisitor { LOG.debug("Error occured while shutting down a connection to '" + transport.getRemoteAddress()+ "': ", e); } finally { stopped.countDown(); - serviceLock.writeLock().unlock(); + if (locked) { + serviceLock.writeLock().unlock(); + } } } }.start();