Program: 103338
Project: 103338
Buggy source:
/** 
 * Handles the <tt>ActionEvent</tt> triggered when one of the items in the list is selected.
 * @param e an <tt>ActionEvent</tt> which carries the data associated withthe performed action
 */
public void actionPerformed(ActionEvent e){
  if (e.getSource() instanceof JMenuItem) {
    String menuItemText=((JMenuItem)e.getSource()).getText();
    LoginManager loginManager=GuiActivator.getUIService().getLoginManager();
    Iterator<PresenceStatus> statusSet=presence.getSupportedStatusSet();
    while (statusSet.hasNext()) {
      PresenceStatus status=statusSet.next();
      if (status.getStatusName().equals(menuItemText)) {
        RegistrationState registrationState=protocolProvider.getRegistrationState();
        if (registrationState == RegistrationState.REGISTERED && !presence.getPresenceStatus().equals(status)) {
          if (status.isOnline()) {
            new PublishPresenceStatusThread(status).start();
          }
 else {
            loginManager.setManuallyDisconnected(true);
            loginManager.logoff(protocolProvider);
          }
          setSelectedStatus(status);
        }
 else         if (registrationState != RegistrationState.REGISTERED && registrationState != RegistrationState.REGISTERING && registrationState != RegistrationState.AUTHENTICATING && status.isOnline()) {
          lastSelectedStatus=status;
          loginManager.login(protocolProvider);
        }
 else         if (!status.isOnline() && !(registrationState == RegistrationState.UNREGISTERING)) {
          loginManager.setManuallyDisconnected(true);
          loginManager.logoff(protocolProvider);
          setSelectedStatus(status);
        }
        saveStatusInformation(protocolProvider,status.getStatusName());
        break;
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Handles the <tt>ActionEvent</tt> triggered when one of the items in the list is selected.
 * @param e an <tt>ActionEvent</tt> which carries the data associated withthe performed action
 */
public void actionPerformed(ActionEvent e){
  if (e.getSource() instanceof JMenuItem) {
    String menuItemText=((JMenuItem)e.getSource()).getText();
    LoginManager loginManager=GuiActivator.getUIService().getLoginManager();
    Iterator<PresenceStatus> statusSet=presence.getSupportedStatusSet();
    while (statusSet.hasNext()) {
      PresenceStatus status=statusSet.next();
      if (status.getStatusName().equals(menuItemText)) {
        RegistrationState registrationState=protocolProvider.getRegistrationState();
        if (registrationState == RegistrationState.REGISTERED && !presence.getPresenceStatus().equals(status)) {
          if (status.isOnline()) {
            new PublishPresenceStatusThread(protocolProvider,status).start();
          }
 else {
            loginManager.setManuallyDisconnected(true);
            loginManager.logoff(protocolProvider);
          }
          setSelectedStatus(status);
        }
 else         if (registrationState != RegistrationState.REGISTERED && registrationState != RegistrationState.REGISTERING && registrationState != RegistrationState.AUTHENTICATING && status.isOnline()) {
          lastSelectedStatus=status;
          loginManager.login(protocolProvider);
        }
 else         if (!status.isOnline() && !(registrationState == RegistrationState.UNREGISTERING)) {
          loginManager.setManuallyDisconnected(true);
          loginManager.logoff(protocolProvider);
          setSelectedStatus(status);
        }
        saveStatusInformation(protocolProvider,status.getStatusName());
        break;
      }
    }
  }
}