You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rh...@apache.org on 2008/02/15 18:49:52 UTC
svn commit: r628132 -
/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java
Author: rhs
Date: Fri Feb 15 09:49:47 2008
New Revision: 628132
URL: http://svn.apache.org/viewvc?rev=628132&view=rev
Log:
protect the _currentException variable with its own lock, this avoids deadlocks between getCurrentException and the dispatcher thread
Modified:
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java
Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java?rev=628132&r1=628131&r2=628132&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java Fri Feb 15 09:49:47 2008
@@ -70,6 +70,7 @@
/**
* The latest qpid Exception that has been reaised.
*/
+ private Object _currentExceptionLock = new Object();
private QpidException _currentException;
/**
@@ -553,14 +554,17 @@
*
* @throws org.apache.qpid.AMQException get the latest thrown error.
*/
- public synchronized void getCurrentException() throws AMQException
+ public void getCurrentException() throws AMQException
{
- if (_currentException != null)
+ synchronized (_currentExceptionLock)
{
- QpidException toBeTrhown = _currentException;
- _currentException = null;
- throw new AMQException(AMQConstant.getConstant(toBeTrhown.getErrorCode().getCode()),
- toBeTrhown.getMessage(), toBeTrhown);
+ if (_currentException != null)
+ {
+ QpidException toBeThrown = _currentException;
+ _currentException = null;
+ throw new AMQException(AMQConstant.getConstant(toBeThrown.getErrorCode().getCode()),
+ toBeThrown.getMessage(), toBeThrown);
+ }
}
}
@@ -594,11 +598,11 @@
{
public void onClosed(ErrorCode errorCode, String reason, Throwable t)
{
- synchronized (this)
+ synchronized (_currentExceptionLock)
{
- //todo check the error code for finding out if we need to notify the
+ // todo check the error code for finding out if we need to notify the
// JMS connection exception listener
- _currentException = new QpidException(reason, errorCode, null);
+ _currentException = new QpidException(reason, errorCode, t);
}
}
}