summaryrefslogtreecommitdiff
path: root/qpid/java
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2008-08-07 15:50:28 +0000
committerMartin Ritchie <ritchiem@apache.org>2008-08-07 15:50:28 +0000
commit7ad6d44494059c5e1a11f145ce45df8c58160de7 (patch)
treeae482e0eed477622e089de87252cb362b0ba55af /qpid/java
parentb35cc139f0d8126a3581c507196046c4f03923bf (diff)
downloadqpid-python-7ad6d44494059c5e1a11f145ce45df8c58160de7.tar.gz
QPID-1182 : Some of the NullPointerExceptions from the SimpleACLTest are due to the close and the notification overlapping due to the lack of locking. The problem is that the AtomicBoolean _closed is used for control but the AMQSession.checkNotClosed needs to check _closed and then throw any exception in the StateManager. However, in a loop of the SimpleACLTest, I would see _closed == false but then it is set right afterwards but the option to check AMQStateManager and throw the exception is past and the super.Closeable.checkNotClosed is called and throws the JMSException with no linked exception hence the test throws NullPointerException
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@683635 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
-rw-r--r--qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java21
1 files changed, 14 insertions, 7 deletions
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
index c253b8b641..d2ef457c94 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
@@ -494,15 +494,22 @@ public abstract class AMQSession extends Closeable implements Session, QueueSess
public void checkNotClosed() throws JMSException
{
- // if the Connection has closed then we should throw any exception that has occured that we were not waiting for
- AMQStateManager manager = _connection.getProtocolHandler().getStateManager();
- if (isClosed() && manager.getCurrentState().equals(AMQState.CONNECTION_CLOSED) && manager.getLastException() != null)
+ try
{
- JMSException jmse = new IllegalStateException("Object " + toString() + " has been closed");
- jmse.setLinkedException(manager.getLastException());
- throw jmse;
+ super.checkNotClosed();
+ }
+ catch (IllegalStateException ise)
+ {
+ // if the Connection has closed then we should throw any exception that has occured that we were not waiting for
+ AMQStateManager manager = _connection.getProtocolHandler().getStateManager();
+
+ if (manager.getCurrentState().equals(AMQState.CONNECTION_CLOSED) && manager.getLastException() != null)
+ {
+ ise.setLinkedException(manager.getLastException());
+ }
+
+ throw ise;
}
- super.checkNotClosed();
}
public BytesMessage createBytesMessage() throws JMSException