Program: 94440
Project: 94440
Buggy source:
public synchronized Object connect(ID remote,Object data,int timeout) throws ECFException {
  if (connection != null)   throw new ECFException("String_Node_Str");
  if (timeout > 0)   SmackConfiguration.setPacketReplyTimeout(timeout);
  Roster.setDefaultSubscriptionMode(Roster.SUBSCRIPTION_MANUAL);
  final XMPPID jabberURI=getXMPPID(remote);
  String username=jabberURI.getUsername();
  String hostname=jabberURI.getHostname();
  String hostnameOverride=null;
  int atSignIdx=username.lastIndexOf('@');
  if (atSignIdx != -1) {
    hostnameOverride=hostname;
    hostname=username.substring(atSignIdx + 1);
    username=username.substring(0,atSignIdx);
  }
  if (google && hostnameOverride == null) {
    hostnameOverride=GOOGLE_TALK_HOST;
  }
  final String serviceName=hostname;
  serverPort=jabberURI.getPort();
  serverResource=jabberURI.getResourceName();
  if (serverResource == null || serverResource.equals(XMPPID.PATH_DELIMITER)) {
    serverResource=getClientIdentifier();
    jabberURI.setResourceName(serverResource);
  }
  try {
    if (hostnameOverride != null) {
      if (secure) {
        if (serverPort == -1) {
          serverPort=XMPPS_DEFAULT_PORT;
        }
        connection=new SSLXMPPConnection(hostnameOverride,serverPort,serviceName);
      }
 else {
        if (serverPort == -1) {
          serverPort=XMPP_DEFAULT_PORT;
        }
        connection=new XMPPConnection(hostnameOverride,serverPort,serviceName);
      }
    }
 else     if (serverPort == -1) {
      if (secure) {
        connection=new SSLXMPPConnection(serviceName);
      }
 else {
        connection=new XMPPConnection(serviceName);
      }
    }
 else {
      if (secure) {
        connection=new SSLXMPPConnection(serviceName,serverPort);
      }
 else {
        connection=new XMPPConnection(serviceName,serverPort);
      }
    }
    connection.addPacketListener(packetListener,null);
    connection.addConnectionListener(connectionListener);
    connection.login(username,(String)data,serverResource);
    isConnected=true;
  }
 catch (  final XMPPException e) {
    if (e.getMessage().equals("String_Node_Str"))     throw new ContainerAuthenticationException("String_Node_Str",e);
    throw new ContainerConnectException(e.getLocalizedMessage(),e);
  }
  return null;
}

Fixed version (ground truth):
public synchronized Object connect(ID remote,Object data,int timeout) throws ECFException {
  if (connection != null)   throw new ECFException("String_Node_Str");
  if (timeout > 0)   SmackConfiguration.setPacketReplyTimeout(timeout);
  Roster.setDefaultSubscriptionMode(Roster.SUBSCRIPTION_MANUAL);
  final XMPPID jabberURI=getXMPPID(remote);
  String username=jabberURI.getNodename();
  String hostname=jabberURI.getHostname();
  String hostnameOverride=null;
  int semiColonIdx=hostname.lastIndexOf(';');
  if (semiColonIdx != -1) {
    hostnameOverride=hostname.substring(semiColonIdx + 1);
    hostname=hostname.substring(0,semiColonIdx);
  }
  if (google && hostnameOverride == null) {
    hostnameOverride=GOOGLE_TALK_HOST;
  }
  final String serviceName=hostname;
  serverPort=jabberURI.getPort();
  serverResource=jabberURI.getResourceName();
  if (serverResource == null || serverResource.equals(XMPPID.PATH_DELIMITER)) {
    serverResource=getClientIdentifier();
    jabberURI.setResourceName(serverResource);
  }
  try {
    if (hostnameOverride != null) {
      if (secure) {
        if (serverPort == -1) {
          serverPort=XMPPS_DEFAULT_PORT;
        }
        connection=new SSLXMPPConnection(hostnameOverride,serverPort,serviceName);
      }
 else {
        if (serverPort == -1) {
          serverPort=XMPP_DEFAULT_PORT;
        }
        connection=new XMPPConnection(hostnameOverride,serverPort,serviceName);
      }
    }
 else     if (serverPort == -1) {
      if (secure) {
        connection=new SSLXMPPConnection(serviceName);
      }
 else {
        connection=new XMPPConnection(serviceName);
      }
    }
 else {
      if (secure) {
        connection=new SSLXMPPConnection(serviceName,serverPort);
      }
 else {
        connection=new XMPPConnection(serviceName,serverPort);
      }
    }
    connection.addPacketListener(packetListener,null);
    connection.addConnectionListener(connectionListener);
    connection.login(username,(String)data,serverResource);
    isConnected=true;
  }
 catch (  final XMPPException e) {
    if (e.getMessage().equals("String_Node_Str"))     throw new ContainerAuthenticationException("String_Node_Str",e);
    throw new ContainerConnectException(e.getLocalizedMessage(),e);
  }
  return null;
}