From ef3a12f42c3c882a81f9aaeed7f87b0bdad89725 Mon Sep 17 00:00:00 2001 From: Martin Ritchie Date: Tue, 18 Nov 2008 11:02:07 +0000 Subject: QPID-1454 : Synchronize round the setting and usage of _failoverLatch, with a new lock. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@718554 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/qpid/client/protocol/AMQProtocolHandler.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'java/client/src') diff --git a/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java b/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java index 20beec5cc4..2389c9e2da 100644 --- a/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java +++ b/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java @@ -164,6 +164,9 @@ public class AMQProtocolHandler extends IoHandlerAdapter /** Defines the default timeout to use for synchronous protocol commands. */ private final long DEFAULT_SYNC_TIMEOUT = Long.getLong("amqj.default_syncwrite_timeout", 1000 * 30); + /** Object to lock on when changing the latch */ + private Object _failoverLatchChange = new Object(); + /** * Creates a new protocol handler, associated with the specified client connection instance. * @@ -774,9 +777,12 @@ public class AMQProtocolHandler extends IoHandlerAdapter public void blockUntilNotFailingOver() throws InterruptedException { - if (_failoverLatch != null) + synchronized(_failoverLatchChange) { - _failoverLatch.await(); + if (_failoverLatch != null) + { + _failoverLatch.await(); + } } } @@ -792,7 +798,10 @@ public class AMQProtocolHandler extends IoHandlerAdapter public void setFailoverLatch(CountDownLatch failoverLatch) { - _failoverLatch = failoverLatch; + synchronized (_failoverLatchChange) + { + _failoverLatch = failoverLatch; + } } public AMQConnection getConnection() -- cgit v1.2.1