Program: 20519
Project: 20519
Buggy source:
/** 
 * Logs in to the server using the strongest authentication mode supported by the server, then set our presence to available. If more than five seconds elapses in each step of the authentication process without a response from the server, or if an error occurs, a XMPPException will be thrown.
 * @param username the username.
 * @param password the password.
 * @param resource the resource.
 * @throws XMPPException if an error occurs.
 * @throws IllegalStateException if not connected to the server, or already logged into the serrver.
 */
public synchronized void login(String username,String password,String resource) throws XMPPException {
  if (!isConnected()) {
    throw new IllegalStateException("String_Node_Str");
  }
  if (authenticated) {
    throw new IllegalStateException("String_Node_Str");
  }
  this.username=username;
  this.resource=resource;
  Authentication discoveryAuth=new Authentication();
  discoveryAuth.setType(IQ.Type.GET);
  discoveryAuth.setUsername(username);
  PacketCollector collector=packetReader.createPacketCollector(new PacketIDFilter(discoveryAuth.getPacketID()));
  packetWriter.sendPacket(discoveryAuth);
  IQ response=(IQ)collector.nextResult(5000);
  if (response == null) {
    throw new XMPPException("String_Node_Str");
  }
 else   if (response.getType() == IQ.Type.ERROR) {
    throw new XMPPException(response.getError());
  }
  Authentication authTypes=(Authentication)response;
  collector.cancel();
  Authentication auth=new Authentication();
  auth.setUsername(username);
  if (authTypes.getDigest() != null) {
    auth.setDigest(connectionID,password);
  }
 else   if (authTypes.getPassword() != null) {
    auth.setPassword(password);
  }
 else {
    throw new XMPPException("String_Node_Str");
  }
  auth.setResource(resource);
  collector=packetReader.createPacketCollector(new PacketIDFilter(auth.getPacketID()));
  packetWriter.sendPacket(auth);
  response=(IQ)collector.nextResult(5000);
  if (response == null) {
    throw new XMPPException("String_Node_Str");
  }
 else   if (response.getType() == IQ.Type.ERROR) {
    throw new XMPPException(response.getError());
  }
  collector.cancel();
  packetWriter.sendPacket(new Presence(Presence.Type.AVAILABLE));
  this.roster=new Roster(this);
  roster.reload();
  authenticated=true;
  if (DEBUG_ENABLED) {
    String title="String_Node_Str" + username + "String_Node_Str"+ getHost()+ "String_Node_Str"+ getPort();
    if (resource != null) {
      title+="String_Node_Str" + resource;
    }
    debugFrame.setTitle(title);
  }
}

Fixed version (ground truth):
/** 
 * Logs in to the server using the strongest authentication mode supported by the server, then set our presence to available. If more than five seconds elapses in each step of the authentication process without a response from the server, or if an error occurs, a XMPPException will be thrown.
 * @param username the username.
 * @param password the password.
 * @param resource the resource.
 * @throws XMPPException if an error occurs.
 * @throws IllegalStateException if not connected to the server, or already logged into the serrver.
 */
public synchronized void login(String username,String password,String resource) throws XMPPException {
  if (!isConnected()) {
    throw new IllegalStateException("String_Node_Str");
  }
  if (authenticated) {
    throw new IllegalStateException("String_Node_Str");
  }
  this.username=username;
  this.resource=resource;
  Authentication discoveryAuth=new Authentication();
  discoveryAuth.setType(IQ.Type.GET);
  discoveryAuth.setUsername(username);
  PacketCollector collector=packetReader.createPacketCollector(new PacketIDFilter(discoveryAuth.getPacketID()));
  packetWriter.sendPacket(discoveryAuth);
  IQ response=(IQ)collector.nextResult(5000);
  if (response == null) {
    throw new XMPPException("String_Node_Str");
  }
 else   if (response.getType() == IQ.Type.ERROR) {
    throw new XMPPException(response.getError());
  }
  Authentication authTypes=(Authentication)response;
  collector.cancel();
  Authentication auth=new Authentication();
  auth.setUsername(username);
  if (authTypes.getDigest() != null) {
    auth.setDigest(connectionID,password);
  }
 else   if (authTypes.getPassword() != null) {
    auth.setPassword(password);
  }
 else {
    throw new XMPPException("String_Node_Str");
  }
  auth.setResource(resource);
  collector=packetReader.createPacketCollector(new PacketIDFilter(auth.getPacketID()));
  packetWriter.sendPacket(auth);
  response=(IQ)collector.nextResult(5000);
  if (response == null) {
    throw new XMPPException("String_Node_Str");
  }
 else   if (response.getType() == IQ.Type.ERROR) {
    throw new XMPPException(response.getError());
  }
  collector.cancel();
  this.roster=new Roster(this);
  roster.reload();
  packetWriter.sendPacket(new Presence(Presence.Type.AVAILABLE));
  authenticated=true;
  if (DEBUG_ENABLED) {
    String title="String_Node_Str" + username + "String_Node_Str"+ getHost()+ "String_Node_Str"+ getPort();
    if (resource != null) {
      title+="String_Node_Str" + resource;
    }
    debugFrame.setTitle(title);
  }
}