You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ri...@apache.org on 2008/11/18 12:02:08 UTC

svn commit: r718554 - /incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java

Author: ritchiem
Date: Tue Nov 18 03:02:07 2008
New Revision: 718554

URL: http://svn.apache.org/viewvc?rev=718554&view=rev
Log:
QPID-1454 : Synchronize round the setting and usage of _failoverLatch, with a new lock.

Modified:
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java?rev=718554&r1=718553&r2=718554&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java Tue Nov 18 03:02:07 2008
@@ -164,6 +164,9 @@
     /** 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 void blockUntilNotFailingOver() throws InterruptedException
     {
-        if (_failoverLatch != null)
+        synchronized(_failoverLatchChange)
         {
-            _failoverLatch.await();
+            if (_failoverLatch != null)
+            {
+                _failoverLatch.await();
+            }
         }
     }
 
@@ -792,7 +798,10 @@
 
     public void setFailoverLatch(CountDownLatch failoverLatch)
     {
-        _failoverLatch = failoverLatch;
+        synchronized (_failoverLatchChange)
+        {
+            _failoverLatch = failoverLatch;
+        }
     }
 
     public AMQConnection getConnection()