diff options
| author | Robert Gemmell <robbie@apache.org> | 2012-11-03 15:15:23 +0000 |
|---|---|---|
| committer | Robert Gemmell <robbie@apache.org> | 2012-11-03 15:15:23 +0000 |
| commit | 75069345199f32452f918a11df9b28b35525450b (patch) | |
| tree | 160dd2ef686359a50399e6f5eb2098a5ab7b2ac7 /java | |
| parent | f79f97f0dc61c54d81e43406d30a437c2e94b3cd (diff) | |
| download | qpid-python-75069345199f32452f918a11df9b28b35525450b.tar.gz | |
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 <phil@philharveyonline.com> plus some additional modifications of my own.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1405354 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
| -rw-r--r-- | java/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java | 12 | ||||
| -rw-r--r-- | java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java | 24 |
2 files changed, 29 insertions, 7 deletions
diff --git a/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java b/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java index 2e7410f906..f038fc6e4f 100644 --- a/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java +++ b/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java @@ -36,6 +36,7 @@ import org.apache.qpid.framing.ConnectionCloseBody; 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 ConnectionCloseMethodHandler implements StateAwareMethodListener<Co } // 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. + } } } diff --git a/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java b/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java index be3d5fc540..af89000c5c 100644 --- a/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java +++ b/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java @@ -56,6 +56,7 @@ import org.apache.qpid.protocol.AMQMethodListener; 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 implements ProtocolEngine */ 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 { |
