Program: 104450
Project: 104450
Buggy source:
/** 
 * Starts the registration process. Connection details such as registration server, user name/number are provided through the configuration service through implementation specific properties.
 * @param authority the security authority that will be used for resolvingany security challenges that may be returned during the registration or at any moment while wer're registered.
 * @throws OperationFailedException with the corresponding code it theregistration fails for some reason (e.g. a networking error or an implementation problem).
 */
public void register(SecurityAuthority authority) throws OperationFailedException {
  if (authority == null)   throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
synchronized (initializationLock) {
    ProtocolProviderFactoryIcqImpl protocolProviderFactory=null;
    if (USING_ICQ)     protocolProviderFactory=IcqActivator.getIcqProtocolProviderFactory();
 else     protocolProviderFactory=IcqActivator.getAimProtocolProviderFactory();
    String password=protocolProviderFactory.loadPassword(getAccountID());
    if (password == null) {
      UserCredentials credentials=new UserCredentials();
      credentials.setUserName(this.getAccountID().getUserID());
      credentials=authority.obtainCredentials(getProtocolName(),credentials);
      char[] pass=credentials.getPassword();
      if (pass == null) {
        fireRegistrationStateChanged(RegistrationState.UNREGISTERED,RegistrationState.UNREGISTERED,RegistrationStateChangeEvent.REASON_USER_REQUEST,"String_Node_Str");
        return;
      }
      password=new String(pass);
      if (credentials.isPasswordPersistent()) {
        protocolProviderFactory.storePassword(getAccountID(),password);
      }
    }
    if (password.length() > 8)     password=password.substring(0,8);
    session=new DefaultAppSession();
    aimSession=session.openAimSession(new Screenname(getAccountID().getUserID()));
    aimConnection=aimSession.openConnection(new AimConnectionProperties(new Screenname(getAccountID().getUserID()),password));
    String proxyAddress=(String)getAccountID().getAccountProperties().get(ProtocolProviderFactory.PROXY_ADDRESS);
    if (proxyAddress != null && proxyAddress.length() > 0) {
      String proxyPortStr=(String)getAccountID().getAccountProperties().get(ProtocolProviderFactory.PROXY_PORT);
      int proxyPort;
      try {
        proxyPort=Integer.parseInt(proxyPortStr);
      }
 catch (      NumberFormatException ex) {
        throw new OperationFailedException("String_Node_Str",OperationFailedException.INVALID_ACCOUNT_PROPERTIES,ex);
      }
      String proxyType=(String)getAccountID().getAccountProperties().get(ProtocolProviderFactory.PROXY_TYPE);
      if (proxyType == null)       throw new OperationFailedException("String_Node_Str",OperationFailedException.INVALID_ACCOUNT_PROPERTIES);
      String proxyUsername=(String)getAccountID().getAccountProperties().get(ProtocolProviderFactory.PROXY_USERNAME);
      String proxyPassword=(String)getAccountID().getAccountProperties().get(ProtocolProviderFactory.PROXY_PASSWORD);
      if (proxyType.equals("String_Node_Str"))       aimConnection.setProxy(AimProxyInfo.forHttp(proxyAddress,proxyPort,proxyUsername,proxyPassword));
 else       if (proxyType.equals("String_Node_Str"))       aimConnection.setProxy(AimProxyInfo.forSocks4(proxyAddress,proxyPort,proxyUsername));
 else       if (proxyType.equals("String_Node_Str"))       aimConnection.setProxy(AimProxyInfo.forSocks5(proxyAddress,proxyPort,proxyUsername,proxyPassword));
    }
    aimConnStateListener=new AimConnStateListener();
    aimConnection.addStateListener(aimConnStateListener);
    aimConnection.connect();
  }
}

Fixed version (ground truth):
/** 
 * Starts the registration process. Connection details such as registration server, user name/number are provided through the configuration service through implementation specific properties.
 * @param authority the security authority that will be used for resolvingany security challenges that may be returned during the registration or at any moment while wer're registered.
 * @throws OperationFailedException with the corresponding code it theregistration fails for some reason (e.g. a networking error or an implementation problem).
 */
public void register(SecurityAuthority authority) throws OperationFailedException {
  if (authority == null)   throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
synchronized (initializationLock) {
    ProtocolProviderFactoryIcqImpl protocolProviderFactory=null;
    if (USING_ICQ)     protocolProviderFactory=IcqActivator.getIcqProtocolProviderFactory();
 else     protocolProviderFactory=IcqActivator.getAimProtocolProviderFactory();
    String password=protocolProviderFactory.loadPassword(getAccountID());
    if (password == null) {
      UserCredentials credentials=new UserCredentials();
      credentials.setUserName(this.getAccountID().getUserID());
      credentials=authority.obtainCredentials(getProtocolName(),credentials);
      if (credentials == null) {
        fireRegistrationStateChanged(getRegistrationState(),RegistrationState.UNREGISTERED,RegistrationStateChangeEvent.REASON_USER_REQUEST,"String_Node_Str");
        return;
      }
      char[] pass=credentials.getPassword();
      if (pass == null) {
        fireRegistrationStateChanged(RegistrationState.UNREGISTERED,RegistrationState.UNREGISTERED,RegistrationStateChangeEvent.REASON_USER_REQUEST,"String_Node_Str");
        return;
      }
      password=new String(pass);
      if (credentials.isPasswordPersistent()) {
        protocolProviderFactory.storePassword(getAccountID(),password);
      }
    }
    if (password.length() > 8)     password=password.substring(0,8);
    session=new DefaultAppSession();
    aimSession=session.openAimSession(new Screenname(getAccountID().getUserID()));
    aimConnection=aimSession.openConnection(new AimConnectionProperties(new Screenname(getAccountID().getUserID()),password));
    String proxyAddress=(String)getAccountID().getAccountProperties().get(ProtocolProviderFactory.PROXY_ADDRESS);
    if (proxyAddress != null && proxyAddress.length() > 0) {
      String proxyPortStr=(String)getAccountID().getAccountProperties().get(ProtocolProviderFactory.PROXY_PORT);
      int proxyPort;
      try {
        proxyPort=Integer.parseInt(proxyPortStr);
      }
 catch (      NumberFormatException ex) {
        throw new OperationFailedException("String_Node_Str",OperationFailedException.INVALID_ACCOUNT_PROPERTIES,ex);
      }
      String proxyType=(String)getAccountID().getAccountProperties().get(ProtocolProviderFactory.PROXY_TYPE);
      if (proxyType == null)       throw new OperationFailedException("String_Node_Str",OperationFailedException.INVALID_ACCOUNT_PROPERTIES);
      String proxyUsername=(String)getAccountID().getAccountProperties().get(ProtocolProviderFactory.PROXY_USERNAME);
      String proxyPassword=(String)getAccountID().getAccountProperties().get(ProtocolProviderFactory.PROXY_PASSWORD);
      if (proxyType.equals("String_Node_Str"))       aimConnection.setProxy(AimProxyInfo.forHttp(proxyAddress,proxyPort,proxyUsername,proxyPassword));
 else       if (proxyType.equals("String_Node_Str"))       aimConnection.setProxy(AimProxyInfo.forSocks4(proxyAddress,proxyPort,proxyUsername));
 else       if (proxyType.equals("String_Node_Str"))       aimConnection.setProxy(AimProxyInfo.forSocks5(proxyAddress,proxyPort,proxyUsername,proxyPassword));
    }
    aimConnStateListener=new AimConnStateListener();
    aimConnection.addStateListener(aimConnStateListener);
    aimConnection.connect();
  }
}