Program: 104077
Project: 104077
Buggy source:
/** 
 * Requests the provider to enter into a status corresponding to the specified paramters.
 * @param status the PresenceStatus as returned bygetRequestableStatusSet
 * @param statusMessage the message that should be set as the reason toenter that status
 * @throws IllegalArgumentException if the status requested is not avalid PresenceStatus supported by this provider.
 * @throws IllegalStateException if the provider is not currentlyregistered.
 * @throws OperationFailedException with code NETWORK_FAILURE ifpublishing the status fails due to a network error.
 */
public void publishPresenceStatus(PresenceStatus status,String statusMessage) throws IllegalArgumentException, IllegalStateException, OperationFailedException {
  assertConnected();
  JabberStatusEnum jabberStatusEnum=parentProvider.getJabberStatusEnum();
  boolean isValidStatus=false;
  for (Iterator supportedStatusIter=jabberStatusEnum.getSupportedStatusSet(); supportedStatusIter.hasNext(); ) {
    if (supportedStatusIter.next().equals(status)) {
      isValidStatus=true;
      break;
    }
  }
  if (!isValidStatus)   throw new IllegalArgumentException(status + "String_Node_Str");
  Presence presence=null;
  if (status.equals(jabberStatusEnum.getStatus(JabberStatusEnum.OFFLINE))) {
    presence=new Presence(Presence.Type.unavailable);
    parentProvider.unregister();
  }
 else {
    presence=new Presence(Presence.Type.available);
    presence.setMode(presenceStatusToJabberMode(status));
    presence.setPriority(resourcePriority);
    presence.setStatus(statusMessage);
    presence.addExtension(new Version());
    parentProvider.getConnection().sendPacket(presence);
  }
  fireProviderPresenceStatusChangeEvent(currentStatus,status);
  if (!getCurrentStatusMessage().equals(statusMessage)) {
    String oldStatusMessage=getCurrentStatusMessage();
    currentStatusMessage=statusMessage;
    fireProviderStatusMessageChangeEvent(oldStatusMessage,getCurrentStatusMessage());
  }
}

Fixed version (ground truth):
/** 
 * Requests the provider to enter into a status corresponding to the specified paramters.
 * @param status the PresenceStatus as returned bygetRequestableStatusSet
 * @param statusMessage the message that should be set as the reason toenter that status
 * @throws IllegalArgumentException if the status requested is not avalid PresenceStatus supported by this provider.
 * @throws IllegalStateException if the provider is not currentlyregistered.
 * @throws OperationFailedException with code NETWORK_FAILURE ifpublishing the status fails due to a network error.
 */
public void publishPresenceStatus(PresenceStatus status,String statusMessage) throws IllegalArgumentException, IllegalStateException, OperationFailedException {
  assertConnected();
  JabberStatusEnum jabberStatusEnum=parentProvider.getJabberStatusEnum();
  boolean isValidStatus=false;
  for (Iterator<PresenceStatus> supportedStatusIter=jabberStatusEnum.getSupportedStatusSet(); supportedStatusIter.hasNext(); ) {
    if (supportedStatusIter.next().equals(status)) {
      isValidStatus=true;
      break;
    }
  }
  if (!isValidStatus)   throw new IllegalArgumentException(status + "String_Node_Str");
  Presence presence=null;
  if (status.equals(jabberStatusEnum.getStatus(JabberStatusEnum.OFFLINE))) {
    presence=new Presence(Presence.Type.unavailable);
    parentProvider.unregister();
  }
 else {
    presence=new Presence(Presence.Type.available);
    presence.setMode(presenceStatusToJabberMode(status));
    presence.setPriority(resourcePriority);
    presence.setStatus(statusMessage);
    presence.addExtension(new Version());
    parentProvider.getConnection().sendPacket(presence);
  }
  fireProviderPresenceStatusChangeEvent(currentStatus,status);
  if (!getCurrentStatusMessage().equals(statusMessage)) {
    String oldStatusMessage=getCurrentStatusMessage();
    currentStatusMessage=statusMessage;
    fireProviderStatusMessageChangeEvent(oldStatusMessage,getCurrentStatusMessage());
  }
}