Repository: qpid-jms Updated Branches: refs/heads/master 05d83c6f7 -> a3ae2856c
Better handling of close on a resource that was remotely closed already. Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/a3ae2856 Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/a3ae2856 Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/a3ae2856 Branch: refs/heads/master Commit: a3ae2856c67b6ad18ce684175929ffbd57c1d2e3 Parents: 05d83c6 Author: Timothy Bish <[email protected]> Authored: Tue Jan 13 15:36:26 2015 -0500 Committer: Timothy Bish <[email protected]> Committed: Tue Jan 13 15:36:53 2015 -0500 ---------------------------------------------------------------------- .../jms/provider/amqp/AmqpAbstractResource.java | 23 ++++++++++++++------ .../qpid/jms/provider/amqp/AmqpConnection.java | 2 ++ 2 files changed, 18 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/a3ae2856/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpAbstractResource.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpAbstractResource.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpAbstractResource.java index cd15122..090fb1a 100644 --- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpAbstractResource.java +++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpAbstractResource.java @@ -99,7 +99,15 @@ public abstract class AmqpAbstractResource<R extends JmsResource, E extends Endp @Override public void close(AsyncResult request) { // If already closed signal success or else the caller might never get notified. - if (getEndpoint().getLocalState() == EndpointState.CLOSED) { + if (getEndpoint().getLocalState() == EndpointState.CLOSED || + getEndpoint().getRemoteState() == EndpointState.CLOSED) { + + // Remote already closed this resource, close locally and free. + if (getEndpoint().getLocalState() != EndpointState.CLOSED) { + doClose(); + getEndpoint().free(); + } + request.onSuccess(); return; } @@ -137,9 +145,9 @@ public abstract class AmqpAbstractResource<R extends JmsResource, E extends Endp @Override public void failed(Exception cause) { if (openRequest != null) { - if(endpoint != null) { - //TODO: if this is a producer/consumer link then we may only be detached, - //rather than fully closed, and should respond appropriately. + if (endpoint != null) { + // TODO: if this is a producer/consumer link then we may only be detached, + // rather than fully closed, and should respond appropriately. endpoint.close(); } openRequest.onFailure(cause); @@ -160,9 +168,9 @@ public abstract class AmqpAbstractResource<R extends JmsResource, E extends Endp error = new IOException("Remote has closed without error information"); } - if(endpoint != null) { - //TODO: if this is a producer/consumer link then we may only be detached, - //rather than fully closed, and should respond appropriately. + if (endpoint != null) { + // TODO: if this is a producer/consumer link then we may only be detached, + // rather than fully closed, and should respond appropriately. endpoint.close(); } @@ -171,6 +179,7 @@ public abstract class AmqpAbstractResource<R extends JmsResource, E extends Endp } // TODO - We need a way to signal that the remote closed unexpectedly. + LOG.info("Resource was remotely closed"); } public E getEndpoint() { http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/a3ae2856/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnection.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnection.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnection.java index 2f7bf05..4c1d60e 100644 --- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnection.java +++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnection.java @@ -153,8 +153,10 @@ public class AmqpConnection extends AmqpAbstractResource<JmsConnectionInfo, Conn LOG.info("Error condition detected on Connection open {}.", getEndpoint().getRemoteCondition().getCondition()); Exception remoteError = getRemoteError(); if (isAwaitingOpen()) { + doClose(); openRequest.onFailure(remoteError); } else { + doClose(); provider.fireProviderException(remoteError); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
