From ddd769ed901ea44163dd154ea978957d5dddeed7 Mon Sep 17 00:00:00 2001 From: Martin Ritchie Date: Mon, 17 Mar 2008 17:44:56 +0000 Subject: QPID-857 : Reset the State Manager when receiveing a CLOSED state. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2.1@637989 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/qpid/client/AMQConnection.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'java/client/src') diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java b/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java index 7a54617bf1..8cbcda053b 100644 --- a/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java +++ b/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java @@ -539,19 +539,25 @@ public class AMQConnection extends Closeable implements Connection, QueueConnect { TransportConnection.getInstance(brokerDetail).connect(_protocolHandler, brokerDetail); - // this blocks until the connection has been set up or when an error - // has prevented the connection being set up + // this blocks until the connection has been set up or when an error + // has prevented the connection being set up //_protocolHandler.attainState(AMQState.CONNECTION_OPEN); AMQState state = _protocolHandler.attainState(openOrClosedStates); - if(state == AMQState.CONNECTION_OPEN) + if (state == AMQState.CONNECTION_OPEN) { - _failoverPolicy.attainedConnection(); // Again this should be changed to a suitable notify _connected = true; } + else if (state == AMQState.CONNECTION_CLOSED) + { + //We need to change protocol handler here as an error during the connect will not + // cause the StateManager to be replaced. So the state is out of sync on reconnect + // This occurs here when we need to re-negotiate protocol versions + _protocolHandler.getStateManager().changeState(AMQState.CONNECTION_NOT_STARTED); + } } catch (AMQException e) { -- cgit v1.2.1