Program: 103336
Project: 103336
Buggy source:
/** 
 * Handles the <tt>ActionEvent</tt> triggered when one of the items in the list is selected.
 * @param e the <tt>ActionEvent</tt> that notified us
 */
public void actionPerformed(ActionEvent e){
  JMenuItem menuItem=(JMenuItem)e.getSource();
  String itemName=menuItem.getName();
  Iterator<ProtocolProviderService> pProviders=mainFrame.getProtocolProviders();
  while (pProviders.hasNext()) {
    ProtocolProviderService protocolProvider=pProviders.next();
    if (itemName.equals(Constants.ONLINE_STATUS)) {
      if (!protocolProvider.isRegistered()) {
        saveStatusInformation(protocolProvider,onlineItem.getName());
        GuiActivator.getUIService().getLoginManager().login(protocolProvider);
      }
 else {
        OperationSetPresence presence=protocolProvider.getOperationSet(OperationSetPresence.class);
        if (presence == null) {
          saveStatusInformation(protocolProvider,onlineItem.getName());
          continue;
        }
        Iterator<PresenceStatus> statusSet=presence.getSupportedStatusSet();
        while (statusSet.hasNext()) {
          PresenceStatus status=statusSet.next();
          if (status.getStatus() < PresenceStatus.EAGER_TO_COMMUNICATE_THRESHOLD && status.getStatus() >= PresenceStatus.AVAILABLE_THRESHOLD) {
            new PublishPresenceStatusThread(presence,status).start();
            this.saveStatusInformation(protocolProvider,status.getStatusName());
            break;
          }
        }
      }
    }
 else     if (itemName.equals(Constants.OFFLINE_STATUS)) {
      if (!protocolProvider.getRegistrationState().equals(RegistrationState.UNREGISTERED) && !protocolProvider.getRegistrationState().equals(RegistrationState.UNREGISTERING)) {
        OperationSetPresence presence=protocolProvider.getOperationSet(OperationSetPresence.class);
        if (presence == null) {
          saveStatusInformation(protocolProvider,offlineItem.getName());
          GuiActivator.getUIService().getLoginManager().logoff(protocolProvider);
          continue;
        }
        Iterator<PresenceStatus> statusSet=presence.getSupportedStatusSet();
        while (statusSet.hasNext()) {
          PresenceStatus status=statusSet.next();
          if (status.getStatus() < PresenceStatus.ONLINE_THRESHOLD) {
            this.saveStatusInformation(protocolProvider,status.getStatusName());
            break;
          }
        }
        try {
          GuiActivator.getUIService().getLoginManager().setManuallyDisconnected(true);
          protocolProvider.unregister();
        }
 catch (        OperationFailedException e1) {
          logger.error("String_Node_Str" + protocolProvider + "String_Node_Str"+ e1);
        }
      }
    }
 else     if (itemName.equals(Constants.FREE_FOR_CHAT_STATUS)) {
      publishStatus(protocolProvider,PresenceStatus.AVAILABLE_THRESHOLD,PresenceStatus.MAX_STATUS_VALUE);
    }
 else     if (itemName.equals(Constants.DO_NOT_DISTURB_STATUS)) {
      publishStatus(protocolProvider,PresenceStatus.ONLINE_THRESHOLD,PresenceStatus.AWAY_THRESHOLD);
    }
 else     if (itemName.equals(Constants.AWAY_STATUS)) {
      publishStatus(protocolProvider,PresenceStatus.AWAY_THRESHOLD,PresenceStatus.AVAILABLE_THRESHOLD);
    }
  }
}

Fixed version (ground truth):
/** 
 * Handles the <tt>ActionEvent</tt> triggered when one of the items in the list is selected.
 * @param e the <tt>ActionEvent</tt> that notified us
 */
public void actionPerformed(ActionEvent e){
  JMenuItem menuItem=(JMenuItem)e.getSource();
  String itemName=menuItem.getName();
  Iterator<ProtocolProviderService> pProviders=mainFrame.getProtocolProviders();
  while (pProviders.hasNext()) {
    ProtocolProviderService protocolProvider=pProviders.next();
    if (itemName.equals(Constants.ONLINE_STATUS)) {
      if (!protocolProvider.isRegistered()) {
        saveStatusInformation(protocolProvider,onlineItem.getName());
        GuiActivator.getUIService().getLoginManager().login(protocolProvider);
      }
 else {
        OperationSetPresence presence=protocolProvider.getOperationSet(OperationSetPresence.class);
        if (presence == null) {
          saveStatusInformation(protocolProvider,onlineItem.getName());
          continue;
        }
        Iterator<PresenceStatus> statusSet=presence.getSupportedStatusSet();
        while (statusSet.hasNext()) {
          PresenceStatus status=statusSet.next();
          if (status.getStatus() < PresenceStatus.EAGER_TO_COMMUNICATE_THRESHOLD && status.getStatus() >= PresenceStatus.AVAILABLE_THRESHOLD) {
            new PublishPresenceStatusThread(protocolProvider,presence,status).start();
            this.saveStatusInformation(protocolProvider,status.getStatusName());
            break;
          }
        }
      }
    }
 else     if (itemName.equals(Constants.OFFLINE_STATUS)) {
      if (!protocolProvider.getRegistrationState().equals(RegistrationState.UNREGISTERED) && !protocolProvider.getRegistrationState().equals(RegistrationState.UNREGISTERING)) {
        OperationSetPresence presence=protocolProvider.getOperationSet(OperationSetPresence.class);
        if (presence == null) {
          saveStatusInformation(protocolProvider,offlineItem.getName());
          GuiActivator.getUIService().getLoginManager().logoff(protocolProvider);
          continue;
        }
        Iterator<PresenceStatus> statusSet=presence.getSupportedStatusSet();
        while (statusSet.hasNext()) {
          PresenceStatus status=statusSet.next();
          if (status.getStatus() < PresenceStatus.ONLINE_THRESHOLD) {
            this.saveStatusInformation(protocolProvider,status.getStatusName());
            break;
          }
        }
        try {
          GuiActivator.getUIService().getLoginManager().setManuallyDisconnected(true);
          protocolProvider.unregister();
        }
 catch (        OperationFailedException e1) {
          logger.error("String_Node_Str" + protocolProvider + "String_Node_Str"+ e1);
        }
      }
    }
 else     if (itemName.equals(Constants.FREE_FOR_CHAT_STATUS)) {
      publishStatus(protocolProvider,PresenceStatus.AVAILABLE_THRESHOLD,PresenceStatus.MAX_STATUS_VALUE);
    }
 else     if (itemName.equals(Constants.DO_NOT_DISTURB_STATUS)) {
      publishStatus(protocolProvider,PresenceStatus.ONLINE_THRESHOLD,PresenceStatus.AWAY_THRESHOLD);
    }
 else     if (itemName.equals(Constants.AWAY_STATUS)) {
      publishStatus(protocolProvider,PresenceStatus.AWAY_THRESHOLD,PresenceStatus.AVAILABLE_THRESHOLD);
    }
  }
}