Program: 104505
Project: 104505
Buggy source:
/** 
 * Connects and logins to the server
 * @param authority SecurityAuthority
 * @throws XMPPException if we cannot connect to the server - network problem
 * @throws OperationFailedException if login parametersas server port are not correct
 */
private void connectAndLogin(SecurityAuthority authority) throws XMPPException, OperationFailedException {
synchronized (initializationLock) {
    String password=JabberActivator.getProtocolProviderFactory().loadPassword(getAccountID());
    if (password == null) {
      UserCredentials credentials=new UserCredentials();
      credentials.setUserName(getAccountID().getUserID());
      credentials=authority.obtainCredentials(ProtocolNames.JABBER,credentials);
      char[] pass=credentials.getPassword();
      if (pass == null) {
        fireRegistrationStateChanged(getRegistrationState(),RegistrationState.UNREGISTERED,RegistrationStateChangeEvent.REASON_USER_REQUEST,"String_Node_Str");
        return;
      }
      password=new String(pass);
      if (credentials.isPasswordPersistent()) {
        JabberActivator.getProtocolProviderFactory().storePassword(getAccountID(),password);
      }
    }
    try {
      String userID=StringUtils.parseName(getAccountID().getUserID());
      String serviceName=StringUtils.parseServer(getAccountID().getUserID());
      String serverAddress=(String)getAccountID().getAccountProperties().get(ProtocolProviderFactory.SERVER_ADDRESS);
      String serverPort=(String)getAccountID().getAccountProperties().get(ProtocolProviderFactory.SERVER_PORT);
      try {
        String hosts[]=NetworkUtils.getSRVRecords("String_Node_Str" + serviceName);
        if (hosts != null && hosts.length > 0) {
          logger.trace("String_Node_Str" + hosts[0]);
          serverAddress=hosts[0];
        }
      }
 catch (      NamingException ex1) {
        logger.error("String_Node_Str" + ex1.getMessage());
      }
      Roster.setDefaultSubscriptionMode(Roster.SUBSCRIPTION_MANUAL);
      connection=new XMPPConnection(serverAddress,Integer.parseInt(serverPort),serviceName);
      connection.addConnectionListener(new JabberConnectionListener());
      connection.login(userID,password,"String_Node_Str");
      if (connection.isAuthenticated()) {
        connection.getRoster().setSubscriptionMode(Roster.SUBSCRIPTION_MANUAL);
        fireRegistrationStateChanged(getRegistrationState(),RegistrationState.REGISTERED,RegistrationStateChangeEvent.REASON_NOT_SPECIFIED,null);
      }
    }
 catch (    NumberFormatException ex) {
      throw new OperationFailedException("String_Node_Str",OperationFailedException.INVALID_ACCOUNT_PROPERTIES,ex);
    }
  }
}

Fixed version (ground truth):
/** 
 * Connects and logins to the server
 * @param authority SecurityAuthority
 * @throws XMPPException if we cannot connect to the server - network problem
 * @throws OperationFailedException if login parametersas server port are not correct
 */
private void connectAndLogin(SecurityAuthority authority) throws XMPPException, OperationFailedException {
synchronized (initializationLock) {
    String password=JabberActivator.getProtocolProviderFactory().loadPassword(getAccountID());
    if (password == null) {
      UserCredentials credentials=new UserCredentials();
      credentials.setUserName(getAccountID().getUserID());
      credentials=authority.obtainCredentials(ProtocolNames.JABBER,credentials);
      char[] pass=credentials.getPassword();
      if (pass == null) {
        fireRegistrationStateChanged(getRegistrationState(),RegistrationState.UNREGISTERED,RegistrationStateChangeEvent.REASON_USER_REQUEST,"String_Node_Str");
        return;
      }
      password=new String(pass);
      if (credentials.isPasswordPersistent()) {
        JabberActivator.getProtocolProviderFactory().storePassword(getAccountID(),password);
      }
    }
    try {
      String userID=StringUtils.parseName(getAccountID().getUserID());
      String serviceName=StringUtils.parseServer(getAccountID().getUserID());
      String serverAddress=(String)getAccountID().getAccountProperties().get(ProtocolProviderFactory.SERVER_ADDRESS);
      String serverPort=(String)getAccountID().getAccountProperties().get(ProtocolProviderFactory.SERVER_PORT);
      try {
        String hosts[]=NetworkUtils.getSRVRecords("String_Node_Str" + serviceName);
        if (hosts != null && hosts.length > 0) {
          logger.trace("String_Node_Str" + hosts[0]);
          serverAddress=hosts[0];
        }
      }
 catch (      NamingException ex1) {
        logger.error("String_Node_Str" + ex1.getMessage());
      }
      Roster.setDefaultSubscriptionMode(Roster.SUBSCRIPTION_MANUAL);
      connection=new XMPPConnection(serverAddress,Integer.parseInt(serverPort),serviceName);
      connection.addConnectionListener(new JabberConnectionListener());
      connection.login(userID,password,"String_Node_Str");
      if (connection.isAuthenticated()) {
        this.reconnecting=false;
        connection.getRoster().setSubscriptionMode(Roster.SUBSCRIPTION_MANUAL);
        fireRegistrationStateChanged(getRegistrationState(),RegistrationState.REGISTERED,RegistrationStateChangeEvent.REASON_NOT_SPECIFIED,null);
      }
    }
 catch (    NumberFormatException ex) {
      throw new OperationFailedException("String_Node_Str",OperationFailedException.INVALID_ACCOUNT_PROPERTIES,ex);
    }
  }
}