You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2012/11/03 16:15:23 UTC

svn commit: r1405354 - in /qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client: handler/ConnectionCloseMethodHandler.java protocol/AMQProtocolHandler.java

Author: robbie
Date: Sat Nov  3 15:15:23 2012
New Revision: 1405354

URL: http://svn.apache.org/viewvc?rev=1405354&view=rev
Log:
QPID-4289, QPID-4344: restore catching of TransportExceptions when trying to close the sender in CCMH. Add TransportException to the 'connection problem' types, and catch any exceptions when trying to close the network connection as a result.

Patch from Philip Harvey <ph...@philharveyonline.com> plus some additional modifications of my own.

Modified:
    qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java
    qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java

Modified: qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java?rev=1405354&r1=1405353&r2=1405354&view=diff
==============================================================================
--- qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java (original)
+++ qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java Sat Nov  3 15:15:23 2012
@@ -36,6 +36,7 @@ import org.apache.qpid.framing.Connectio
 import org.apache.qpid.framing.ConnectionCloseOkBody;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.transport.Sender;
+import org.apache.qpid.transport.TransportException;
 
 public class ConnectionCloseMethodHandler implements StateAwareMethodListener<ConnectionCloseBody>
 {
@@ -102,7 +103,16 @@ public class ConnectionCloseMethodHandle
             }
 
             // Close the open TCP connection
-            sender.close();
+            try
+            {
+                sender.close();
+            }
+            catch(TransportException e)
+            {
+                //Ignore, they are already logged by the Sender and this
+                //is a connection-close being processed by the IoReceiver
+                //which will as it closes initiate failover if necessary.
+            }
         }
     }
 

Modified: qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java?rev=1405354&r1=1405353&r2=1405354&view=diff
==============================================================================
--- qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java (original)
+++ qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java Sat Nov  3 15:15:23 2012
@@ -56,6 +56,7 @@ import org.apache.qpid.protocol.AMQMetho
 import org.apache.qpid.protocol.ProtocolEngine;
 import org.apache.qpid.thread.Threading;
 import org.apache.qpid.transport.Sender;
+import org.apache.qpid.transport.TransportException;
 import org.apache.qpid.transport.network.NetworkConnection;
 
 import java.io.IOException;
@@ -67,7 +68,6 @@ import java.util.Set;
 import java.util.concurrent.CopyOnWriteArraySet;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
 
 /**
  * AMQProtocolHandler is the client side protocol handler for AMQP, it handles all protocol events received from the
@@ -317,17 +317,29 @@ public class AMQProtocolHandler implemen
      */
     public void exception(Throwable cause)
     {
-        boolean connectionClosed = (cause instanceof AMQConnectionClosedException || cause instanceof IOException);
-        if (connectionClosed)
+        boolean causeIsAConnectionProblem =
+                cause instanceof AMQConnectionClosedException ||
+                cause instanceof IOException ||
+                cause instanceof TransportException;
+
+        if (causeIsAConnectionProblem)
         {
-            _network.close();
+            //ensure the IoSender and IoReceiver are closed
+            try
+            {
+                _network.close();
+            }
+            catch (Exception e)
+            {
+                //ignore
+            }
         }
         FailoverState state = getFailoverState();
         if (state == FailoverState.NOT_STARTED)
         {
-            if (connectionClosed)
+            if (causeIsAConnectionProblem)
             {
-                _logger.info("Exception caught therefore going to attempt failover: " + cause, cause);
+                _logger.info("Connection exception caught therefore going to attempt failover: " + cause, cause);
             }
             else
             {



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org