Program: 104405
Project: 104405
Buggy source:
/** 
 * The method is called by a ProtocolProvider implementation whenver 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() == RegistrationState.UNREGISTERING) {
    timer.cancel();
    try {
      publishPresenceStatus(SipStatusEnum.OFFLINE,"String_Node_Str");
    }
 catch (    OperationFailedException e) {
      logger.error("String_Node_Str",e);
    }
    Thread t=new Thread(new unregisteringThread());
    t.setDaemon(false);
    t.start();
    PresenceStatus oldStatus=presenceStatus;
    presenceStatus=SipStatusEnum.OFFLINE;
    fireProviderStatusChangeEvent(oldStatus);
  }
 else   if (evt.getNewState().equals(RegistrationState.REGISTERED)) {
    logger.debug("String_Node_Str");
    Iterator groupsIter=getServerStoredContactListRoot().subgroups();
    while (groupsIter.hasNext()) {
      ContactGroupSipImpl group=(ContactGroupSipImpl)groupsIter.next();
      Iterator contactsIter=group.contacts();
      while (contactsIter.hasNext()) {
        ContactSipImpl contact=(ContactSipImpl)contactsIter.next();
        if (contact.isResolved()) {
          logger.debug("String_Node_Str" + contact + "String_Node_Str");
          continue;
        }
        Request subscription;
        try {
          subscription=createSubscription(contact,SUBSCRIBE_DEFAULT_EXPIRE);
        }
 catch (        OperationFailedException ex) {
          logger.error("String_Node_Str",ex);
          return;
        }
        ClientTransaction subscribeTransaction;
        SipProvider jainSipProvider=parentProvider.getDefaultJainSipProvider();
        try {
          subscribeTransaction=jainSipProvider.getNewClientTransaction(subscription);
        }
 catch (        TransactionUnavailableException ex) {
          logger.error("String_Node_Str" + "String_Node_Str" + "String_Node_Str",ex);
          return;
        }
        CallIdHeader idheader=(CallIdHeader)subscription.getHeader(CallIdHeader.NAME);
        subscribedContacts.put(idheader.getCallId(),contact);
        logger.debug("String_Node_Str" + idheader.getCallId());
        try {
          subscribeTransaction.sendRequest();
        }
 catch (        SipException ex) {
          logger.error("String_Node_Str",ex);
          subscribedContacts.remove(idheader.getCallId());
          return;
        }
      }
    }
    timer=new Timer(true);
    pollingTask=new PollOfflineContactsTask();
    timer.schedule(pollingTask,POLLING_TASK_PERIOD,POLLING_TASK_PERIOD);
  }
}

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. 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() == RegistrationState.UNREGISTERING) {
    timer.cancel();
    try {
      publishPresenceStatus(SipStatusEnum.OFFLINE,"String_Node_Str");
    }
 catch (    OperationFailedException e) {
      logger.error("String_Node_Str",e);
    }
    for (byte i=0; i < 10; i++) {
synchronized (waitedCallIds) {
        if (waitedCallIds.size() == 0) {
          break;
        }
      }
synchronized (this) {
        try {
          wait(500);
        }
 catch (        InterruptedException e) {
          logger.debug("String_Node_Str" + "String_Node_Str",e);
        }
      }
    }
    PresenceStatus oldStatus=presenceStatus;
    presenceStatus=SipStatusEnum.OFFLINE;
    fireProviderStatusChangeEvent(oldStatus);
  }
 else   if (evt.getNewState().equals(RegistrationState.REGISTERED)) {
    logger.debug("String_Node_Str");
    Iterator groupsIter=getServerStoredContactListRoot().subgroups();
    while (groupsIter.hasNext()) {
      ContactGroupSipImpl group=(ContactGroupSipImpl)groupsIter.next();
      Iterator contactsIter=group.contacts();
      while (contactsIter.hasNext()) {
        ContactSipImpl contact=(ContactSipImpl)contactsIter.next();
        if (contact.isResolved()) {
          logger.debug("String_Node_Str" + contact + "String_Node_Str");
          continue;
        }
        forcePollContact(contact);
      }
    }
    timer=new Timer(true);
    pollingTask=new PollOfflineContactsTask();
    timer.schedule(pollingTask,POLLING_TASK_PERIOD,POLLING_TASK_PERIOD);
  }
}