Program: 104161
Project: 104161
Buggy source:
/** 
 * The method is called by a ProtocolProvider implementation whenver a change in the registration state of the corresponding provider had occurred.
 * @param evt ProviderStatusChangeEvent the event describing the statuschange.
 */
public void registrationStateChanged(RegistrationStateChangeEvent evt){
  logger.debug("String_Node_Str" + evt.getOldState() + "String_Node_Str"+ evt.getNewState());
  if (evt.getNewState() == RegistrationState.REGISTERED) {
    parentProvider.getYahooSession().addSessionListener(new StatusChangedListener());
    ssContactList.setYahooSession(parentProvider.getYahooSession());
    initContactStatuses();
    addSubscriptionListener(statusUpdater);
  }
 else   if (evt.getNewState() == RegistrationState.UNREGISTERED || evt.getNewState() == RegistrationState.AUTHENTICATION_FAILED || evt.getNewState() == RegistrationState.CONNECTION_FAILED) {
    PresenceStatus oldStatus=currentStatus;
    currentStatus=YahooStatusEnum.OFFLINE;
    fireProviderPresenceStatusChangeEvent(oldStatus,currentStatus);
    removeSubscriptionListener(statusUpdater);
    Iterator groupsIter=getServerStoredContactListRoot().subgroups();
    while (groupsIter.hasNext()) {
      ContactGroupYahooImpl group=(ContactGroupYahooImpl)groupsIter.next();
      Iterator contactsIter=group.contacts();
      while (contactsIter.hasNext()) {
        ContactYahooImpl contact=(ContactYahooImpl)contactsIter.next();
        PresenceStatus oldContactStatus=contact.getPresenceStatus();
        if (!oldContactStatus.isOnline())         continue;
        contact.updatePresenceStatus(YahooStatusEnum.OFFLINE);
        fireContactPresenceStatusChangeEvent(contact,contact.getParentContactGroup(),oldContactStatus,YahooStatusEnum.OFFLINE);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * The method is called by a ProtocolProvider implementation whenver a change in the registration state of the corresponding provider had occurred.
 * @param evt ProviderStatusChangeEvent the event describing the statuschange.
 */
public void registrationStateChanged(RegistrationStateChangeEvent evt){
  logger.debug("String_Node_Str" + evt.getOldState() + "String_Node_Str"+ evt.getNewState());
  if (evt.getNewState() == RegistrationState.REGISTERING) {
    earlyEventListener=new EarlyEventListener();
    parentProvider.getYahooSession().addSessionListener(earlyEventListener);
  }
 else   if (evt.getNewState() == RegistrationState.REGISTERED) {
    parentProvider.getYahooSession().addSessionListener(new StatusChangedListener());
    ssContactList.setYahooSession(parentProvider.getYahooSession());
    initContactStatuses();
    addSubscriptionListener(statusUpdater);
    if (earlyEventListener != null) {
      parentProvider.getYahooSession().removeSessionListener(earlyEventListener);
    }
  }
 else   if (evt.getNewState() == RegistrationState.UNREGISTERED || evt.getNewState() == RegistrationState.AUTHENTICATION_FAILED || evt.getNewState() == RegistrationState.CONNECTION_FAILED) {
    PresenceStatus oldStatus=currentStatus;
    currentStatus=YahooStatusEnum.OFFLINE;
    fireProviderPresenceStatusChangeEvent(oldStatus,currentStatus);
    removeSubscriptionListener(statusUpdater);
    Iterator groupsIter=getServerStoredContactListRoot().subgroups();
    while (groupsIter.hasNext()) {
      ContactGroupYahooImpl group=(ContactGroupYahooImpl)groupsIter.next();
      Iterator contactsIter=group.contacts();
      while (contactsIter.hasNext()) {
        ContactYahooImpl contact=(ContactYahooImpl)contactsIter.next();
        PresenceStatus oldContactStatus=contact.getPresenceStatus();
        if (!oldContactStatus.isOnline())         continue;
        contact.updatePresenceStatus(YahooStatusEnum.OFFLINE);
        fireContactPresenceStatusChangeEvent(contact,contact.getParentContactGroup(),oldContactStatus,YahooStatusEnum.OFFLINE);
      }
    }
    parentProvider.getYahooSession().removeSessionListener(earlyEventListener);
    earlyEventListener=null;
  }
}