Program: 20451
Project: 20451
Buggy source:
/** 
 * Begin the initial connection to the server.  Returns when the connection is established.
 */
public void initializeConnection() throws XMPPException {
  if (socket != null)   throw new RuntimeException("String_Node_Str");
  String host=config.getHost();
  int port=config.getPort();
  if (host == null) {
    DNSUtil.XMPPDomainLookup lookup=new DNSUtil.XMPPDomainLookup(config.getServiceName(),true);
    Vector<DNSUtil.HostAddress> addresses=lookup.run();
    if (discoveryIndex >= addresses.size())     throw new XMPPException("String_Node_Str" + addresses.size() + "String_Node_Str",XMPPError.Condition.remote_server_not_found);
    host=addresses.get(discoveryIndex).getHost();
    port=addresses.get(discoveryIndex).getPort();
  }
  try {
    socket=config.getSocketFactory().createSocket(host,port);
    initReaderAndWriter();
  }
 catch (  UnknownHostException e) {
    throw new XMPPException("String_Node_Str" + host + "String_Node_Str"+ port,e);
  }
catch (  IOException e) {
    throw new XMPPException("String_Node_Str" + host + "String_Node_Str"+ port,e);
  }
  while (true) {
    Element packet=readPacket();
    if (packet == null)     throw new XMPPException("String_Node_Str");
    try {
      if (processInitializationPacket(packet)) {
        continue;
      }
    }
 catch (    IOException e) {
      throw new XMPPException("String_Node_Str",e);
    }
    bufferedPacket=packet;
    config.setHost(host);
    config.setPort(port);
    startKeepAliveProcess();
    return;
  }
}

Fixed version (ground truth):
/** 
 * Begin the initial connection to the server.  Returns when the connection is established.
 */
public void initializeConnection() throws XMPPException {
  if (socket != null)   throw new RuntimeException("String_Node_Str");
  String host=config.getHost();
  int port=config.getPort();
  if (host == null) {
    DNSUtil.XMPPDomainLookup lookup=new DNSUtil.XMPPDomainLookup(config.getServiceName(),true);
    Vector<DNSUtil.HostAddress> addresses=lookup.run();
    if (discoveryIndex >= addresses.size())     throw new XMPPException("String_Node_Str" + addresses.size() + "String_Node_Str",XMPPError.Condition.remote_server_not_found);
    host=addresses.get(discoveryIndex).getHost();
    port=addresses.get(discoveryIndex).getPort();
  }
 else {
    if (discoveryIndex > 0)     throw new XMPPException("String_Node_Str",XMPPError.Condition.remote_server_not_found);
  }
  try {
    socket=config.getSocketFactory().createSocket(host,port);
    initReaderAndWriter();
  }
 catch (  UnknownHostException e) {
    throw new XMPPException("String_Node_Str" + host + "String_Node_Str"+ port,e);
  }
catch (  IOException e) {
    throw new XMPPException("String_Node_Str" + host + "String_Node_Str"+ port,e);
  }
  while (true) {
    Element packet=readPacket();
    if (packet == null)     throw new XMPPException("String_Node_Str");
    try {
      if (processInitializationPacket(packet)) {
        continue;
      }
    }
 catch (    IOException e) {
      throw new XMPPException("String_Node_Str",e);
    }
    bufferedPacket=packet;
    config.setHost(host);
    config.setPort(port);
    startKeepAliveProcess();
    return;
  }
}