Program: 94610
Project: 94610
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);
  final String username=jabberURI.getUsername();
  serverName=jabberURI.getHostname();
  serverPort=jabberURI.getPort();
  serverResource=jabberURI.getResourceName();
  if (serverResource == null || serverResource.equals(XMPPID.PATH_DELIMITER)) {
    serverResource=getClientIdentifier();
    jabberURI.setResourceName(serverResource);
  }
  try {
    if (google) {
      if (secure) {
        if (serverPort == -1) {
          serverPort=XMPPS_DEFAULT_PORT;
        }
        connection=new SSLXMPPConnection(GOOGLE_TALK_HOST,serverPort,jabberURI.getHostname());
      }
 else {
        if (serverPort == -1) {
          serverPort=XMPP_DEFAULT_PORT;
        }
        connection=new XMPPConnection(GOOGLE_TALK_HOST,serverPort,jabberURI.getHostname());
      }
    }
 else     if (serverPort == -1) {
      if (secure) {
        connection=new SSLXMPPConnection(serverName);
      }
 else {
        connection=new XMPPConnection(serverName);
      }
    }
 else {
      if (secure) {
        connection=new SSLXMPPConnection(serverName,serverPort);
      }
 else {
        connection=new XMPPConnection(serverName,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);
  final String username=jabberURI.getNodename();
  serverName=jabberURI.getHostname();
  serverPort=jabberURI.getPort();
  serverResource=jabberURI.getResourceName();
  if (serverResource == null || serverResource.equals(XMPPID.PATH_DELIMITER)) {
    serverResource=getClientIdentifier();
    jabberURI.setResourceName(serverResource);
  }
  try {
    if (google) {
      if (secure) {
        if (serverPort == -1) {
          serverPort=XMPPS_DEFAULT_PORT;
        }
        connection=new SSLXMPPConnection(GOOGLE_TALK_HOST,serverPort,jabberURI.getHostname());
      }
 else {
        if (serverPort == -1) {
          serverPort=XMPP_DEFAULT_PORT;
        }
        connection=new XMPPConnection(GOOGLE_TALK_HOST,serverPort,jabberURI.getHostname());
      }
    }
 else     if (serverPort == -1) {
      if (secure) {
        connection=new SSLXMPPConnection(serverName);
      }
 else {
        connection=new XMPPConnection(serverName);
      }
    }
 else {
      if (secure) {
        connection=new SSLXMPPConnection(serverName,serverPort);
      }
 else {
        connection=new XMPPConnection(serverName,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;
}