diff options
| author | Rafael H. Schloming <rhs@apache.org> | 2008-02-15 17:49:47 +0000 |
|---|---|---|
| committer | Rafael H. Schloming <rhs@apache.org> | 2008-02-15 17:49:47 +0000 |
| commit | 491b221e39621eb9977c6bfa76f3587870d0d3a4 (patch) | |
| tree | 0ce987205a9529df6fe33d55ce8c95dc3cf2067d /qpid/java/client | |
| parent | dec38809ed3d95cc022138d2a5704f27b70ca9f9 (diff) | |
| download | qpid-python-491b221e39621eb9977c6bfa76f3587870d0d3a4.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@628132 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/client')
| -rw-r--r-- | qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java index dd2b9a2389..407f1f3786 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java +++ b/qpid/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); } } } |
