From f67415d8799a540dc7d1bc9a52862b4b9f2a5a60 Mon Sep 17 00:00:00 2001 From: Robert Davies Date: Wed, 12 Mar 2008 17:04:44 +0000 Subject: [PATCH] don't wait for ever when stopping the connection on a blocked write git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@636419 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/activemq/broker/TransportConnection.java | 9 +++++++-- 1 file changed, 7 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 1c9e6421f7..977e30a2d4 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 @@ -607,7 +607,7 @@ public class TransportConnection implements Connection, Task, CommandVisitor { if( wireFormatInfo!=null && wireFormatInfo.getVersion() <= 2 ) { info.setClientMaster(true); } - + TransportConnectionState state; // Make sure 2 concurrent connections by the same ID only generate 1 @@ -890,7 +890,12 @@ public class TransportConnection implements Connection, Task, CommandVisitor { @Override public void run() { // make sure we are not servicing client requests while we are shutting down. - serviceLock.writeLock().lock(); + try { + //we could be waiting a long time if the network has gone - so only wait 1 second + serviceLock.writeLock().tryLock(1,TimeUnit.SECONDS); + } catch (InterruptedException e) { + LOG.debug("Try get writeLock interrupted ",e); + } try { doStop(); } catch (Throwable e) {