Program: 104086
Project: 104086
Buggy source:
/** 
 * Persistently adds a subscription for the presence status of the contact corresponding to the specified contactIdentifier and indicates that it should be added to the specified group of the server stored contact list.
 * @param parentGroup the parent group of the server stored contact listwhere the contact should be added. <p>
 * @param contactIdentifier the contact whose status updates we aresubscribing for.
 * @throws IllegalArgumentException if <tt>contact</tt> or<tt>parent</tt> are not a contact known to the underlying protocol provider.
 * @throws IllegalStateException if the underlying protocol provider isnot registered/signed on a public service.
 * @throws OperationFailedException with code NETWORK_FAILURE ifsubscribing fails due to errors experienced during network communication
 */
public void subscribe(ContactGroup parentGroup,String contactIdentifier) throws IllegalArgumentException, IllegalStateException, OperationFailedException {
  logger.debug("String_Node_Str" + contactIdentifier);
  ContactSipImpl contact=(ContactSipImpl)resolveContactID(contactIdentifier);
  if (contact != null && contact.isPersistent()) {
    throw new OperationFailedException("String_Node_Str" + contactIdentifier + "String_Node_Str",OperationFailedException.SUBSCRIPTION_ALREADY_EXISTS);
  }
 else   if (!contact.isPersistent()) {
    ContactGroupSipImpl oldParentGroup=(ContactGroupSipImpl)contact.getParentContactGroup();
    oldParentGroup.removeContact(contact);
    fireSubscriptionEvent(contact,oldParentGroup,SubscriptionEvent.SUBSCRIPTION_REMOVED);
  }
  Address contactAddress;
  try {
    contactAddress=parentProvider.parseAddressString(contactIdentifier);
  }
 catch (  ParseException exc) {
    throw new IllegalArgumentException(contactIdentifier + "String_Node_Str",exc);
  }
  contact=new ContactSipImpl(contactAddress,this.parentProvider);
  ((ContactGroupSipImpl)parentGroup).addContact(contact);
  fireSubscriptionEvent(contact,parentGroup,SubscriptionEvent.SUBSCRIPTION_CREATED);
  if (this.presenceEnabled == false)   return;
  assertConnected();
  Request subscription;
  try {
    subscription=createSubscription(contact,this.subscriptionDuration);
  }
 catch (  OperationFailedException ex) {
    logger.error("String_Node_Str",ex);
    throw new OperationFailedException("String_Node_Str",OperationFailedException.INTERNAL_ERROR);
  }
  ClientTransaction subscribeTransaction;
  SipProvider jainSipProvider=this.parentProvider.getDefaultJainSipProvider();
  try {
    subscribeTransaction=jainSipProvider.getNewClientTransaction(subscription);
  }
 catch (  TransactionUnavailableException ex) {
    logger.error("String_Node_Str" + "String_Node_Str",ex);
    throw new OperationFailedException("String_Node_Str",OperationFailedException.NETWORK_FAILURE);
  }
  CallIdHeader idheader=(CallIdHeader)subscription.getHeader(CallIdHeader.NAME);
  this.subscribedContacts.put(idheader.getCallId(),contact);
  try {
    subscribeTransaction.sendRequest();
  }
 catch (  SipException ex) {
    logger.error("String_Node_Str",ex);
    this.subscribedContacts.remove(idheader.getCallId());
    throw new OperationFailedException("String_Node_Str",OperationFailedException.NETWORK_FAILURE);
  }
}

Fixed version (ground truth):
/** 
 * Persistently adds a subscription for the presence status of the contact corresponding to the specified contactIdentifier and indicates that it should be added to the specified group of the server stored contact list.
 * @param parentGroup the parent group of the server stored contact listwhere the contact should be added. <p>
 * @param contactIdentifier the contact whose status updates we aresubscribing for.
 * @throws IllegalArgumentException if <tt>contact</tt> or<tt>parent</tt> are not a contact known to the underlying protocol provider.
 * @throws IllegalStateException if the underlying protocol provider isnot registered/signed on a public service.
 * @throws OperationFailedException with code NETWORK_FAILURE ifsubscribing fails due to errors experienced during network communication
 */
public void subscribe(ContactGroup parentGroup,String contactIdentifier) throws IllegalArgumentException, IllegalStateException, OperationFailedException {
  logger.debug("String_Node_Str" + contactIdentifier);
  ContactSipImpl contact=(ContactSipImpl)resolveContactID(contactIdentifier);
  if (contact != null) {
    if (contact.isPersistent()) {
      throw new OperationFailedException("String_Node_Str" + contactIdentifier + "String_Node_Str",OperationFailedException.SUBSCRIPTION_ALREADY_EXISTS);
    }
 else {
      ContactGroupSipImpl oldParentGroup=(ContactGroupSipImpl)contact.getParentContactGroup();
      oldParentGroup.removeContact(contact);
      fireSubscriptionEvent(contact,oldParentGroup,SubscriptionEvent.SUBSCRIPTION_REMOVED);
    }
  }
  Address contactAddress;
  try {
    contactAddress=parentProvider.parseAddressString(contactIdentifier);
  }
 catch (  ParseException exc) {
    throw new IllegalArgumentException(contactIdentifier + "String_Node_Str",exc);
  }
  contact=new ContactSipImpl(contactAddress,this.parentProvider);
  ((ContactGroupSipImpl)parentGroup).addContact(contact);
  fireSubscriptionEvent(contact,parentGroup,SubscriptionEvent.SUBSCRIPTION_CREATED);
  if (this.presenceEnabled == false)   return;
  assertConnected();
  Request subscription;
  try {
    subscription=createSubscription(contact,this.subscriptionDuration);
  }
 catch (  OperationFailedException ex) {
    logger.error("String_Node_Str",ex);
    throw new OperationFailedException("String_Node_Str",OperationFailedException.INTERNAL_ERROR);
  }
  ClientTransaction subscribeTransaction;
  SipProvider jainSipProvider=this.parentProvider.getDefaultJainSipProvider();
  try {
    subscribeTransaction=jainSipProvider.getNewClientTransaction(subscription);
  }
 catch (  TransactionUnavailableException ex) {
    logger.error("String_Node_Str" + "String_Node_Str",ex);
    throw new OperationFailedException("String_Node_Str",OperationFailedException.NETWORK_FAILURE);
  }
  CallIdHeader idheader=(CallIdHeader)subscription.getHeader(CallIdHeader.NAME);
  this.subscribedContacts.put(idheader.getCallId(),contact);
  try {
    subscribeTransaction.sendRequest();
  }
 catch (  SipException ex) {
    logger.error("String_Node_Str",ex);
    this.subscribedContacts.remove(idheader.getCallId());
    throw new OperationFailedException("String_Node_Str",OperationFailedException.NETWORK_FAILURE);
  }
}