You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ri...@apache.org on 2008/08/07 17:50:29 UTC

svn commit: r683635 - /incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java

Author: ritchiem
Date: Thu Aug  7 08:50:28 2008
New Revision: 683635

URL: http://svn.apache.org/viewvc?rev=683635&view=rev
Log:
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

Modified:
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java?rev=683635&r1=683634&r2=683635&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java Thu Aug  7 08:50:28 2008
@@ -494,15 +494,22 @@
 
     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