Program: 103370
Project: 103370
Buggy source:
/** 
 * Creates the ICE agent that we would be using in this transport manager for all negotiation.
 * @return the ICE agent to use for all the ICE negotiation that thistransport manager would be going through
 */
private Agent createIceAgent(){
  CallPeerJabberImpl peer=getCallPeer();
  ProtocolProviderServiceJabberImpl provider=peer.getProtocolProvider();
  NetworkAddressManagerService namSer=getNetAddrMgr();
  boolean atLeastOneStunServer=false;
  Agent agent=namSer.createIceAgent();
  agent.setControlling(!peer.isInitiator());
  JabberAccountID accID=(JabberAccountID)provider.getAccountID();
  if (accID.isStunServerDiscoveryEnabled()) {
    String username=org.jivesoftware.smack.util.StringUtils.parseName(provider.getOurJID());
    String password=JabberActivator.getProtocolProviderFactory().loadPassword(accID);
    if (password == null) {
      UserCredentials credentials=new UserCredentials();
      credentials.setUserName(accID.getUserID());
      credentials=provider.getAuthority().obtainCredentials(ProtocolNames.JABBER,credentials,SecurityAuthority.AUTHENTICATION_REQUIRED);
      if (credentials == null) {
        return null;
      }
      char[] pass=credentials.getPassword();
      if (pass == null) {
        return null;
      }
      password=new String(pass);
      if (credentials.isPasswordPersistent()) {
        JabberActivator.getProtocolProviderFactory().storePassword(accID,password);
      }
    }
    StunCandidateHarvester autoHarvester=namSer.discoverStunServer(accID.getService(),StringUtils.getUTF8Bytes(username),StringUtils.getUTF8Bytes(password));
    if (logger.isInfoEnabled())     logger.info("String_Node_Str" + autoHarvester);
    if (autoHarvester != null) {
      atLeastOneStunServer=true;
      agent.addCandidateHarvester(autoHarvester);
    }
  }
  for (  StunServerDescriptor desc : accID.getStunServers()) {
    TransportAddress addr=new TransportAddress(desc.getAddress(),desc.getPort(),Transport.UDP);
    StunCandidateHarvester harvester;
    if (desc.isTurnSupported()) {
      harvester=new TurnCandidateHarvester(addr,new LongTermCredential(desc.getUsername(),desc.getPassword()));
    }
 else {
      harvester=new StunCandidateHarvester(addr);
    }
    if (logger.isInfoEnabled())     logger.info("String_Node_Str" + harvester);
    atLeastOneStunServer=true;
    agent.addCandidateHarvester(harvester);
  }
  if (!atLeastOneStunServer) {
    if (accID.isUseDefaultStunServer()) {
      TransportAddress addr=new TransportAddress(DEFAULT_STUN_SERVER_ADDRESS,DEFAULT_STUN_SERVER_PORT,Transport.UDP);
      StunCandidateHarvester harvester=new StunCandidateHarvester(addr);
      if (harvester != null) {
        agent.addCandidateHarvester(harvester);
      }
    }
  }
  if (accID.isJingleNodesRelayEnabled()) {
    SmackServiceNode serviceNode=peer.getProtocolProvider().getJingleNodesServiceNode();
    if (serviceNode != null) {
      JingleNodesHarvester harvester=new JingleNodesHarvester(serviceNode);
      if (harvester != null) {
        agent.addCandidateHarvester(harvester);
      }
    }
  }
  if (accID.isUPNPEnabled()) {
    UPNPHarvester harvester=new UPNPHarvester();
    if (harvester != null) {
      agent.addCandidateHarvester(harvester);
    }
  }
  return agent;
}

Fixed version (ground truth):
/** 
 * Creates the ICE agent that we would be using in this transport manager for all negotiation.
 * @return the ICE agent to use for all the ICE negotiation that thistransport manager would be going through
 */
private Agent createIceAgent(){
  CallPeerJabberImpl peer=getCallPeer();
  ProtocolProviderServiceJabberImpl provider=peer.getProtocolProvider();
  NetworkAddressManagerService namSer=getNetAddrMgr();
  boolean atLeastOneStunServer=false;
  Agent agent=namSer.createIceAgent();
  agent.setControlling(!peer.isInitiator());
  JabberAccountID accID=(JabberAccountID)provider.getAccountID();
  if (accID.isStunServerDiscoveryEnabled()) {
    String username=org.jivesoftware.smack.util.StringUtils.parseName(provider.getOurJID());
    String password=JabberActivator.getProtocolProviderFactory().loadPassword(accID);
    if (provider.getUserCredentials() != null)     password=provider.getUserCredentials().getPasswordAsString();
    if (password == null) {
      UserCredentials credentials=new UserCredentials();
      credentials.setUserName(accID.getUserID());
      credentials=provider.getAuthority().obtainCredentials(ProtocolNames.JABBER,credentials,SecurityAuthority.AUTHENTICATION_REQUIRED);
      if (credentials == null) {
        return null;
      }
      char[] pass=credentials.getPassword();
      if (pass == null) {
        return null;
      }
      password=new String(pass);
      if (credentials.isPasswordPersistent()) {
        JabberActivator.getProtocolProviderFactory().storePassword(accID,password);
      }
    }
    StunCandidateHarvester autoHarvester=namSer.discoverStunServer(accID.getService(),StringUtils.getUTF8Bytes(username),StringUtils.getUTF8Bytes(password));
    if (logger.isInfoEnabled())     logger.info("String_Node_Str" + autoHarvester);
    if (autoHarvester != null) {
      atLeastOneStunServer=true;
      agent.addCandidateHarvester(autoHarvester);
    }
  }
  for (  StunServerDescriptor desc : accID.getStunServers()) {
    TransportAddress addr=new TransportAddress(desc.getAddress(),desc.getPort(),Transport.UDP);
    StunCandidateHarvester harvester;
    if (desc.isTurnSupported()) {
      harvester=new TurnCandidateHarvester(addr,new LongTermCredential(desc.getUsername(),desc.getPassword()));
    }
 else {
      harvester=new StunCandidateHarvester(addr);
    }
    if (logger.isInfoEnabled())     logger.info("String_Node_Str" + harvester);
    atLeastOneStunServer=true;
    agent.addCandidateHarvester(harvester);
  }
  if (!atLeastOneStunServer) {
    if (accID.isUseDefaultStunServer()) {
      TransportAddress addr=new TransportAddress(DEFAULT_STUN_SERVER_ADDRESS,DEFAULT_STUN_SERVER_PORT,Transport.UDP);
      StunCandidateHarvester harvester=new StunCandidateHarvester(addr);
      if (harvester != null) {
        agent.addCandidateHarvester(harvester);
      }
    }
  }
  if (accID.isJingleNodesRelayEnabled()) {
    SmackServiceNode serviceNode=peer.getProtocolProvider().getJingleNodesServiceNode();
    if (serviceNode != null) {
      JingleNodesHarvester harvester=new JingleNodesHarvester(serviceNode);
      if (harvester != null) {
        agent.addCandidateHarvester(harvester);
      }
    }
  }
  if (accID.isUPNPEnabled()) {
    UPNPHarvester harvester=new UPNPHarvester();
    if (harvester != null) {
      agent.addCandidateHarvester(harvester);
    }
  }
  return agent;
}