summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael H. Schloming <rhs@apache.org>2008-02-15 17:49:47 +0000
committerRafael H. Schloming <rhs@apache.org>2008-02-15 17:49:47 +0000
commit2895d73ed993c4f9d9e32116bf7c2ea0d3d089e8 (patch)
treecdc504fb6555e3744eaae0f845773991dedf56ac
parente9f4a8f94810b1f43716f4606d3beedec568656e (diff)
downloadqpid-python-2895d73ed993c4f9d9e32116bf7c2ea0d3d089e8.tar.gz
protect the _currentException variable with its own lock, this avoids deadlocks between getCurrentException and the dispatcher thread
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@628132 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java22
1 files changed, 13 insertions, 9 deletions
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java b/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java
index dd2b9a2389..407f1f3786 100644
--- a/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java
+++ b/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java
@@ -70,6 +70,7 @@ public class AMQSession_0_10 extends AMQSession
/**
* The latest qpid Exception that has been reaised.
*/
+ private Object _currentExceptionLock = new Object();
private QpidException _currentException;
/**
@@ -553,14 +554,17 @@ public class AMQSession_0_10 extends AMQSession
*
* @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 class AMQSession_0_10 extends AMQSession
{
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);
}
}
}