From 06e4488afee377347660ea481959dfbfb720ab47 Mon Sep 17 00:00:00 2001 From: Martin Ritchie Date: Thu, 7 Aug 2008 15:50:28 +0000 Subject: 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/qpid@683635 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/qpid/client/AMQSession.java | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'java/client/src') diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQSession.java b/java/client/src/main/java/org/apache/qpid/client/AMQSession.java index c253b8b641..d2ef457c94 100644 --- a/java/client/src/main/java/org/apache/qpid/client/AMQSession.java +++ b/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 -- cgit v1.2.1