Program: 103523
Project: 103523
Buggy source:
/** 
 * The method is called by a ProtocolProvider implementation whenever a change in the registration state of the corresponding provider had occurred. The method is particularly interested in events stating that the SIP provider has unregistered so that it would fire status change events for all contacts in our buddy list.
 * @param evt ProviderStatusChangeEvent the event describing the statuschange.
 */
public void registrationStateChanged(RegistrationStateChangeEvent evt){
  if (evt.getNewState().equals(RegistrationState.UNREGISTERING)) {
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str");
    }
    cancelTimer();
    ssContactList.destroy();
    try {
      publishPresenceStatus(sipStatusEnum.getStatus(SipStatusEnum.OFFLINE),"String_Node_Str");
    }
 catch (    OperationFailedException e) {
      logger.error("String_Node_Str",e);
    }
    stopEvents();
  }
 else   if (evt.getNewState().equals(RegistrationState.REGISTERED)) {
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str");
    }
    ssContactList.init();
    if ((!presenceEnabled) || (pollingTask != null)) {
      return;
    }
    for (    ContactSipImpl contact : ssContactList.getAllContacts(ssContactList.getRootGroup())) {
      forcePollContact(contact);
    }
    pollingTask=new PollOfflineContactsTask();
    timer.schedule(pollingTask,pollingTaskPeriod,pollingTaskPeriod);
  }
 else   if (evt.getNewState().equals(RegistrationState.CONNECTION_FAILED)) {
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str");
    }
    ssContactList.destroy();
    for (    ContactSipImpl contact : ssContactList.getAllContacts(ssContactList.getRootGroup())) {
      PresenceStatus oldContactStatus=contact.getPresenceStatus();
      if (subscriber != null) {
        try {
          subscriber.removeSubscription(getAddress(contact));
        }
 catch (        OperationFailedException ex) {
          if (logger.isDebugEnabled()) {
            logger.debug("String_Node_Str" + contact);
          }
        }
      }
      if (!oldContactStatus.isOnline()) {
        continue;
      }
      contact.setPresenceStatus(sipStatusEnum.getStatus(SipStatusEnum.OFFLINE));
      fireContactPresenceStatusChangeEvent(contact,contact.getParentContactGroup(),oldContactStatus);
    }
    cancelTimer();
    waitedCallIds.clear();
    fireProviderStatusChangeEvent(sipStatusEnum.getStatus(SipStatusEnum.OFFLINE));
  }
}

Fixed version (ground truth):
/** 
 * The method is called by a ProtocolProvider implementation whenever a change in the registration state of the corresponding provider had occurred. The method is particularly interested in events stating that the SIP provider has unregistered so that it would fire status change events for all contacts in our buddy list.
 * @param evt ProviderStatusChangeEvent the event describing the statuschange.
 */
public void registrationStateChanged(RegistrationStateChangeEvent evt){
  if (evt.getNewState().equals(RegistrationState.UNREGISTERING)) {
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str");
    }
    cancelTimer();
    ssContactList.destroy();
    try {
      publishPresenceStatus(sipStatusEnum.getStatus(SipStatusEnum.OFFLINE),"String_Node_Str");
    }
 catch (    OperationFailedException e) {
      logger.error("String_Node_Str",e);
    }
    stopEvents();
  }
 else   if (evt.getNewState().equals(RegistrationState.REGISTERED)) {
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str");
    }
    ssContactList.init();
    if ((!presenceEnabled) || (pollingTask != null)) {
      return;
    }
    for (    ContactSipImpl contact : ssContactList.getAllContacts(ssContactList.getRootGroup())) {
      forcePollContact(contact);
    }
    pollingTask=new PollOfflineContactsTask();
    timer.schedule(pollingTask,pollingTaskPeriod,pollingTaskPeriod);
  }
 else   if (evt.getNewState().equals(RegistrationState.CONNECTION_FAILED)) {
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str");
    }
    ssContactList.destroy();
    for (    ContactSipImpl contact : ssContactList.getAllContacts(ssContactList.getRootGroup())) {
      PresenceStatus oldContactStatus=contact.getPresenceStatus();
      if (subscriber != null) {
        try {
          subscriber.removeSubscription(getAddress(contact));
        }
 catch (        OperationFailedException ex) {
          if (logger.isDebugEnabled()) {
            logger.debug("String_Node_Str" + contact);
          }
        }
      }
      if (!oldContactStatus.isOnline()) {
        continue;
      }
      contact.setPresenceStatus(sipStatusEnum.getStatus(SipStatusEnum.OFFLINE));
      fireContactPresenceStatusChangeEvent(contact,contact.getParentContactGroup(),oldContactStatus);
    }
    cancelTimer();
    waitedCallIds.clear();
    try {
      publishPresenceStatus(sipStatusEnum.getStatus(SipStatusEnum.OFFLINE),"String_Node_Str");
    }
 catch (    OperationFailedException e) {
      logger.error("String_Node_Str",e);
    }
  }
}