summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Simon <arnaudsimon@apache.org>2008-06-05 09:17:40 +0000
committerArnaud Simon <arnaudsimon@apache.org>2008-06-05 09:17:40 +0000
commit674031a9e2e891c99ca1818b46a52684f465ff09 (patch)
tree1a9c2776fba741310c177870b1fbafbe86af03e9
parente6a45336be3d9f5ddc4eae7bbca1c2c2e39ad840 (diff)
downloadqpid-python-674031a9e2e891c99ca1818b46a52684f465ff09.tar.gz
QPID-1123: Added a timeout (threading issue is still to be fixed)
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@663507 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/java/client/src/main/java/org/apache/qpidity/nclient/Client.java18
1 files changed, 14 insertions, 4 deletions
diff --git a/qpid/java/client/src/main/java/org/apache/qpidity/nclient/Client.java b/qpid/java/client/src/main/java/org/apache/qpidity/nclient/Client.java
index 0bd203a8dd..5b45387be3 100644
--- a/qpid/java/client/src/main/java/org/apache/qpidity/nclient/Client.java
+++ b/qpid/java/client/src/main/java/org/apache/qpidity/nclient/Client.java
@@ -25,6 +25,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
+import java.util.concurrent.TimeUnit;
import org.apache.qpid.client.url.URLParser_0_10;
import org.apache.qpid.jms.BrokerDetails;
@@ -255,15 +256,24 @@ public class Client implements org.apache.qpidity.nclient.Connection
_lock.lock();
try
{
- try {
- while (!closed)
+ try
+ {
+ long timeout = 60000;
+ long start = System.currentTimeMillis();
+ long elapsed = 0;
+ while (!closed && elapsed < timeout)
+ {
+ closeOk.await(timeout - elapsed, TimeUnit.MILLISECONDS);
+ elapsed = System.currentTimeMillis() - start;
+ }
+ if(! closed )
{
- closeOk.await();
+ throw new QpidException("Timed out when closing connection", ErrorCode.CONNECTION_ERROR, null);
}
}
catch (InterruptedException e)
{
- // do nothing
+ throw new QpidException("Interrupted when closing connection", ErrorCode.CONNECTION_ERROR, null);
}
}
finally