int actualServerID = r.getActualFailoverNode();
int actualServerID = r.getActualFailoverNodeID();
   private void handleFailure(ClientConnectionDelegate failedConnDelegate) throws Exception   {      ConnectionState failedConnState =         (ConnectionState)((DelegateSupport)failedConnDelegate).getState();      int failedServerID = failedConnState.getServerID();      log.debug(this + " handling failed connection to node " + failedServerID);      // Get the default connection factory delegate we are going to failover onto      ClientConnectionFactoryDelegate failoverDelegate = getFailoverDelegate(failedServerID);      if (failoverDelegate == null)      {         throw new IllegalStateException("Cannot find default failover node for server " +                                         failedServerID);      }      // We attempt to connect to the failover node in a loop, since we might need to go through      // multiple hops      int attemptCount = 0;      outer: while (attemptCount < MAX_RECONNECT_HOP_COUNT)      {         // Create a connection using that connection factory         CreateConnectionResult r = failoverDelegate.            createConnectionDelegate(failedConnState.getUser(),                                     failedConnState.getPassword(),                                     failedConnState.getServerID());         if (r.getDelegate() != null)         {            // We got the right server and created a new connection            performClientSideFailover(failedConnDelegate, (ClientConnectionDelegate)r.getDelegate());            return;         }         // Did not get a valid connection to the node we've just tried         int actualServerID = r.getActualFailoverNode();         if (actualServerID == -1)         {            // No failover attempt was detected on the server side; this might happen if the client            // side network fails temporarily so the client connection breaks but the server cluster            // is still up and running - in this case we don't perform failover.            //TODO Is this the right thing to do?            log.warn("Client attempted failover, but no failover attempt " +                     "has been detected on the server side.");            return;         }         // Server side failover has occurred / is occurring but trying to go to the 'default'         // failover node did not succeed. Retry with the node suggested by the cluster.         attemptCount++;         for (int i = 0; i < delegates.length; i++)         {            if (delegates[i].getServerID() == actualServerID)            {               failoverDelegate = delegates[i];               continue outer;            }         }         // the delegate corresponding to the actualServerID not found among the cached delegates         //TODO Could this ever happen? Should we send back the cf, or update it instead of just the id??         throw new JMSException("Cannot find a cached connection factory delegate for " +                                "node " + actualServerID);      }      throw new JMSException("Maximum number of failover attempts exceeded. " +                             "Cannot find a server to failover onto.");   }