Author: kwall
Date: Thu Feb 18 13:37:09 2016
New Revision: 1731072
URL: http://svn.apache.org/viewvc?rev=1731072&view=rev
Log:
QPID-7077: [Java Client] Make access to _failoverLatch thread safe
* Also added logging to better understand the sporadic NPE.
Modified:
qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQConnection.java
qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQProtocolHandler.java
Modified:
qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQConnection.java
URL:
http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQConnection.java?rev=1731072&r1=1731071&r2=1731072&view=diff
==============================================================================
---
qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQConnection.java
(original)
+++
qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQConnection.java
Thu Feb 18 13:37:09 2016
@@ -124,7 +124,7 @@ public class AMQConnection extends Close
* the handler deals with this. It also deals with the initial dispatch of
any protocol frames to their appropriate
* handler.
*/
- private AMQProtocolHandler _protocolHandler;
+ private final AMQProtocolHandler _protocolHandler;
/** Maps from session id (Integer) to AMQSession instance */
private final ChannelToSessionMap _sessions = new ChannelToSessionMap();
Modified:
qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQProtocolHandler.java
URL:
http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQProtocolHandler.java?rev=1731072&r1=1731071&r2=1731072&view=diff
==============================================================================
---
qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQProtocolHandler.java
(original)
+++
qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQProtocolHandler.java
Thu Feb 18 13:37:09 2016
@@ -109,6 +109,9 @@ public class AMQProtocolHandler implemen
/** Used to provide a condition to wait upon for operations that are
required to wait for failover to complete. */
private CountDownLatch _failoverLatch;
+ /** Object to lock on when changing the _failoverLatch */
+ private final Object _failoverLatchChange = new Object();
+
/** The last failover exception that occurred */
private FailoverException _lastFailoverException;
@@ -116,9 +119,6 @@ public class AMQProtocolHandler implemen
private final long DEFAULT_SYNC_TIMEOUT =
Long.getLong(ClientProperties.QPID_SYNC_OP_TIMEOUT,
Long.getLong(AMQJ_DEFAULT_SYNCWRITE_TIMEOUT,
ClientProperties.DEFAULT_SYNC_OPERATION_TIMEOUT));
-
- /** Object to lock on when changing the latch */
- private Object _failoverLatchChange = new Object();
private ClientDecoder _decoder;
private ProtocolVersion _suggestedProtocolVersion;
@@ -744,13 +744,18 @@ public class AMQProtocolHandler implemen
public CountDownLatch getFailoverLatch()
{
- return _failoverLatch;
+ synchronized (_failoverLatchChange)
+ {
+ _logger.debug("Failover latch retrieved : {}", _failoverLatch);
+ return _failoverLatch;
+ }
}
public void setFailoverLatch(CountDownLatch failoverLatch)
{
synchronized (_failoverLatchChange)
{
+ _logger.debug("Failover latch set : {}", failoverLatch);
_failoverLatch = failoverLatch;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]