Author: ritchiem
Date: Mon Oct 19 11:10:33 2009
New Revision: 826638

URL: http://svn.apache.org/viewvc?rev=826638&view=rev
Log:
QPID-1816 : When client fails over due to an error, that error is still held bt 
the StateManager and will prvent the connection from working. During failover 
check and see if the Connection had been marked closed if so remove any set 
exception.

Modified:
    
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/failover/FailoverHandler.java
    
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/state/AMQStateManager.java

Modified: 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/failover/FailoverHandler.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/failover/FailoverHandler.java?rev=826638&r1=826637&r2=826638&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/failover/FailoverHandler.java
 (original)
+++ 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/failover/FailoverHandler.java
 Mon Oct 19 11:10:33 2009
@@ -24,6 +24,7 @@
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.protocol.AMQProtocolHandler;
 import org.apache.qpid.client.state.AMQStateManager;
+import org.apache.qpid.client.state.AMQState;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -192,6 +193,22 @@
                 // Set the new Protocol Session in the StateManager.           
    
                 
existingStateManager.setProtocolSession(_amqProtocolHandler.getProtocolSession());
 
+                // Now that the ProtocolHandler has been reconnected clean up
+                // the state of the old state manager. As if we simply 
reinstate
+                // it any old exception that had occured prior to failover may
+                // prohibit reconnection.
+                // e.g. During testing when the broker is shutdown gracefully.
+                // The broker 
+                // Clear any exceptions we gathered
+                if (existingStateManager.getCurrentState() != 
AMQState.CONNECTION_OPEN)
+                {
+                    // Clear the state of the previous state manager as it may
+                    // have received an exception
+                    existingStateManager.clearLastException();
+                    existingStateManager.changeState(AMQState.CONNECTION_OPEN);
+                }
+
+
                 //Restore Existing State Manager
                 _amqProtocolHandler.setStateManager(existingStateManager);
                 try

Modified: 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/state/AMQStateManager.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/state/AMQStateManager.java?rev=826638&r1=826637&r2=826638&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/state/AMQStateManager.java
 (original)
+++ 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/state/AMQStateManager.java
 Mon Oct 19 11:10:33 2009
@@ -213,4 +213,9 @@
     {
         return _lastException;
     }
+
+    public void clearLastException()
+    {
+        _lastException = null;
+    }
 }



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

Reply via email to