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 2009/04/11 03:00:39 UTC

svn commit: r764129 - in /qpid/branches/0.5-release/qpid/java: ./ client/src/main/java/org/apache/qpid/client/ systests/src/main/java/org/apache/qpid/test/unit/client/connection/

Author: ritchiem
Date: Sat Apr 11 01:00:39 2009
New Revision: 764129

URL: http://svn.apache.org/viewvc?rev=764129&view=rev
Log:
QPID-1779 : Application of patches attached to JIRA. Should address connection close issues experienced on 0-8/9 branch
    Excluded test from TCP runs as it is hardwired to InVM.

merged from trunk r764109

Added:
    qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/CloseAfterConnectionFailureTest.java
      - copied unchanged from r764109, qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/CloseAfterConnectionFailureTest.java
Modified:
    qpid/branches/0.5-release/qpid/java/010ExcludeList
    qpid/branches/0.5-release/qpid/java/08ExcludeList-nonvm
    qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java
    qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
    qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java
    qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/client/Closeable.java

Modified: qpid/branches/0.5-release/qpid/java/010ExcludeList
URL: http://svn.apache.org/viewvc/qpid/branches/0.5-release/qpid/java/010ExcludeList?rev=764129&r1=764128&r2=764129&view=diff
==============================================================================
--- qpid/branches/0.5-release/qpid/java/010ExcludeList (original)
+++ qpid/branches/0.5-release/qpid/java/010ExcludeList Sat Apr 11 01:00:39 2009
@@ -64,3 +64,6 @@
 // This test currently does not pick up the runtime location of the nonVm queueBacking store.
 org.apache.qpid.test.unit.client.close.FlowToDiskBackingQueueDeleteTest#*
 
+// This test may use QpidTestCase but it is not using the getConnection and is hardwired to InVM
+org.apache.qpid.test.unit.client.connection.CloseAfterConnectionFailureTest#*
+

Modified: qpid/branches/0.5-release/qpid/java/08ExcludeList-nonvm
URL: http://svn.apache.org/viewvc/qpid/branches/0.5-release/qpid/java/08ExcludeList-nonvm?rev=764129&r1=764128&r2=764129&view=diff
==============================================================================
--- qpid/branches/0.5-release/qpid/java/08ExcludeList-nonvm (original)
+++ qpid/branches/0.5-release/qpid/java/08ExcludeList-nonvm Sat Apr 11 01:00:39 2009
@@ -32,3 +32,5 @@
 // This test currently does not pick up the runtime location of the nonVm queueBacking store.
 org.apache.qpid.test.unit.client.close.FlowToDiskBackingQueueDeleteTest#*
 
+// This test may use QpidTestCase but it is not using the getConnection and is hardwired to InVM
+org.apache.qpid.test.unit.client.connection.CloseAfterConnectionFailureTest#*

Modified: qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java?rev=764129&r1=764128&r2=764129&view=diff
==============================================================================
--- qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java (original)
+++ qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java Sat Apr 11 01:00:39 2009
@@ -58,6 +58,7 @@
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQProtocolException;
 import org.apache.qpid.AMQUnresolvedAddressException;
+import org.apache.qpid.AMQDisconnectedException;
 import org.apache.qpid.client.configuration.ClientProperties;
 import org.apache.qpid.client.failover.FailoverException;
 import org.apache.qpid.client.failover.FailoverProtectedOperation;
@@ -924,7 +925,12 @@
     {
         if (!_closed.getAndSet(true))
         {
-            doClose(sessions, timeout);
+            _closing.set(true);
+            try{
+                doClose(sessions, timeout);
+            }finally{
+                _closing.set(false);
+            }
         }
     }
 
@@ -1318,7 +1324,7 @@
         // in the case of an IOException, MINA has closed the protocol session so we set _closed to true
         // so that any generic client code that tries to close the connection will not mess up this error
         // handling sequence
-        if (cause instanceof IOException)
+        if (cause instanceof IOException || cause instanceof AMQDisconnectedException)
         {
             closer = !_closed.getAndSet(true);
 

Modified: qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java?rev=764129&r1=764128&r2=764129&view=diff
==============================================================================
--- qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java (original)
+++ qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java Sat Apr 11 01:00:39 2009
@@ -282,7 +282,7 @@
 
     /** Holds the dispatcher thread for this session. */
     protected Dispatcher _dispatcher;
-    
+
     protected Thread _dispatcherThread;
 
     /** Holds the message factory factory for this session. */
@@ -644,7 +644,11 @@
 
                     try
                     {
-                        sendClose(timeout);
+                        // IF we are closing then send the close.
+                        if (_connection.isClosing())
+                        {
+                            sendClose(timeout);
+                        }
                     }
                     catch (AMQException e)
                     {
@@ -1218,9 +1222,9 @@
 
             // this is done so that we can produce to a temporary queue before we create a consumer
             result.setQueueName(result.getRoutingKey());
-            createQueue(result.getAMQQueueName(), result.isAutoDelete(), 
+            createQueue(result.getAMQQueueName(), result.isAutoDelete(),
                         result.isDurable(), result.isExclusive());
-            bindQueue(result.getAMQQueueName(), result.getRoutingKey(), 
+            bindQueue(result.getAMQQueueName(), result.getRoutingKey(),
                     new FieldTable(), result.getExchangeName(), result);
             return result;
         }
@@ -1682,11 +1686,11 @@
                         // if (rawSelector != null)
                         // ft.put("headers", rawSelector.getDataAsBytes());
                         // rawSelector is used by HeadersExchange and is not a JMS Selector
-                        if (rawSelector != null) 
+                        if (rawSelector != null)
                         {
                             ft.addAll(rawSelector);
                         }
-                        
+
                         if (messageSelector != null)
                         {
                             ft.put(new AMQShortString("x-filter-jms-selector"), messageSelector);
@@ -1936,13 +1940,13 @@
             _dispatcher = new Dispatcher();
             try
             {
-                _dispatcherThread = Threading.getThreadFactory().createThread(_dispatcher);       
-                
+                _dispatcherThread = Threading.getThreadFactory().createThread(_dispatcher);
+
             }
             catch(Exception e)
             {
                 throw new Error("Error creating Dispatcher thread",e);
-            }            
+            }
             _dispatcherThread.setName("Dispatcher-Channel-" + _channelId);
             _dispatcherThread.setDaemon(true);
             _dispatcher.setConnectionStopped(initiallyStopped);

Modified: qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java?rev=764129&r1=764128&r2=764129&view=diff
==============================================================================
--- qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java (original)
+++ qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java Sat Apr 11 01:00:39 2009
@@ -563,7 +563,10 @@
                 {
                     try
                     {
-                        sendCancel();
+                        if (!_connection.isClosing())
+                        {
+                            sendCancel();
+                        }
                     }
                     catch (AMQException e)
                     {

Modified: qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/client/Closeable.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/client/Closeable.java?rev=764129&r1=764128&r2=764129&view=diff
==============================================================================
--- qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/client/Closeable.java (original)
+++ qpid/branches/0.5-release/qpid/java/client/src/main/java/org/apache/qpid/client/Closeable.java Sat Apr 11 01:00:39 2009
@@ -52,6 +52,13 @@
     protected final AtomicBoolean _closed = new AtomicBoolean(false);
 
     /**
+     * Are we in the process of closing. We have this distinction so we can
+     * still signal we are in the process of closing so other objects can tell
+     * the difference and tidy up.
+     */
+    protected final AtomicBoolean _closing = new AtomicBoolean(false);
+
+    /**
      * Checks if this is closed, and raises a JMSException if it is.
      *
      * @throws JMSException If this is closed.
@@ -75,6 +82,17 @@
     }
 
     /**
+     * Checks if this is closis.
+     *
+     * @return <tt>true</tt> if we are closing, <tt>false</tt> otherwise.
+     */
+    public boolean isClosing()
+    {
+        return _closing.get();
+    }
+
+
+    /**
      * Closes this object.
      *
      * @throws JMSException If this cannot be closed for any reason.



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org