Program: 104401
Project: 104401
Buggy source:
/** 
 * Converts the <tt>PresenceStatus</tt> of <tt>contact</tt> into a PIDF document.
 * @param contact The contact which interest us
 * @return a PIDF document representing the current presence status ofthis contact or null if an error occurs.
 */
public byte[] getPidfPresenceStatus(ContactSipImpl contact){
  Document doc=this.createDocument();
  if (doc == null) {
    return null;
  }
  String contactUri=null;
  try {
    contactUri=this.parseAddressStr(contact.getAddress()).getURI().toString();
  }
 catch (  ParseException e) {
    logger.debug("String_Node_Str",e);
    return null;
  }
  Element presence=doc.createElement(PRESENCE_ELEMENT);
  presence.setAttribute(NS_ELEMENT,NS_VALUE);
  presence.setAttribute(RPID_NS_ELEMENT,RPID_NS_VALUE);
  presence.setAttribute(DM_NS_ELEMENT,DM_NS_VALUE);
  presence.setAttribute(ENTITY_ATTRIBUTE,contactUri);
  doc.appendChild(presence);
  Element person=doc.createElement(NS_PERSON_ELT);
  person.setAttribute(ID_ATTRIBUTE,"String_Node_Str" + String.valueOf(tupleid++));
  presence.appendChild(person);
  Element activities=doc.createElement(NS_ACTIVITY_ELT);
  person.appendChild(activities);
  if (getPresenceStatus().equals(SipStatusEnum.AWAY)) {
    Element away=doc.createElement(NS_AWAY_ELT);
    activities.appendChild(away);
  }
 else   if (getPresenceStatus().equals(SipStatusEnum.DO_NOT_DISTURB)) {
    Element busy=doc.createElement(NS_BUSY_ELT);
    activities.appendChild(busy);
  }
  Element tuple=doc.createElement(TUPLE_ELEMENT);
  tuple.setAttribute(ID_ATTRIBUTE,String.valueOf(tupleid++));
  presence.appendChild(tuple);
  Element status=doc.createElement(STATUS_ELEMENT);
  tuple.appendChild(status);
  Element basic=doc.createElement(BASIC_ELEMENT);
  if (this.getPresenceStatus().equals(SipStatusEnum.OFFLINE)) {
    basic.appendChild(doc.createTextNode(OFFLINE_STATUS));
  }
 else {
    basic.appendChild(doc.createTextNode(ONLINE_STATUS));
  }
  status.appendChild(basic);
  Element contactUriEl=doc.createElement(CONTACT_ELEMENT);
  Node cValue=doc.createTextNode(contactUri);
  contactUriEl.appendChild(cValue);
  tuple.appendChild(contactUriEl);
  Element noteNodeEl=doc.createElement(NOTE_ELEMENT);
  noteNodeEl.appendChild(doc.createTextNode(this.getPresenceStatus().getStatusName()));
  tuple.appendChild(noteNodeEl);
  String res=convertDocument(doc);
  if (res == null) {
    return null;
  }
  return res.getBytes();
}

Fixed version (ground truth):
/** 
 * Converts the <tt>PresenceStatus</tt> of <tt>contact</tt> into a PIDF document.
 * @param contact The contact which interest us
 * @return a PIDF document representing the current presence status ofthis contact or null if an error occurs.
 */
public byte[] getPidfPresenceStatus(ContactSipImpl contact){
  Document doc=this.createDocument();
  if (doc == null) {
    return null;
  }
  String contactUri=null;
  try {
    contactUri=this.parseAddressStr(contact.getAddress()).getURI().toString();
  }
 catch (  ParseException e) {
    logger.debug("String_Node_Str",e);
    return null;
  }
  Element presence=doc.createElement(PRESENCE_ELEMENT);
  presence.setAttribute(NS_ELEMENT,NS_VALUE);
  presence.setAttribute(RPID_NS_ELEMENT,RPID_NS_VALUE);
  presence.setAttribute(DM_NS_ELEMENT,DM_NS_VALUE);
  presence.setAttribute(ENTITY_ATTRIBUTE,contactUri);
  doc.appendChild(presence);
  Element person=doc.createElement(NS_PERSON_ELT);
  person.setAttribute(ID_ATTRIBUTE,"String_Node_Str" + String.valueOf(tupleid++));
  presence.appendChild(person);
  Element activities=doc.createElement(NS_ACTIVITY_ELT);
  person.appendChild(activities);
  if (contact.getPresenceStatus().equals(SipStatusEnum.AWAY)) {
    Element away=doc.createElement(NS_AWAY_ELT);
    activities.appendChild(away);
  }
 else   if (contact.getPresenceStatus().equals(SipStatusEnum.DO_NOT_DISTURB)) {
    Element busy=doc.createElement(NS_BUSY_ELT);
    activities.appendChild(busy);
  }
  Element tuple=doc.createElement(TUPLE_ELEMENT);
  tuple.setAttribute(ID_ATTRIBUTE,String.valueOf(tupleid++));
  presence.appendChild(tuple);
  Element status=doc.createElement(STATUS_ELEMENT);
  tuple.appendChild(status);
  Element basic=doc.createElement(BASIC_ELEMENT);
  if (contact.getPresenceStatus().equals(SipStatusEnum.OFFLINE)) {
    basic.appendChild(doc.createTextNode(OFFLINE_STATUS));
  }
 else {
    basic.appendChild(doc.createTextNode(ONLINE_STATUS));
  }
  status.appendChild(basic);
  Element contactUriEl=doc.createElement(CONTACT_ELEMENT);
  Node cValue=doc.createTextNode(contactUri);
  contactUriEl.appendChild(cValue);
  tuple.appendChild(contactUriEl);
  Element noteNodeEl=doc.createElement(NOTE_ELEMENT);
  noteNodeEl.appendChild(doc.createTextNode(contact.getPresenceStatus().getStatusName()));
  tuple.appendChild(noteNodeEl);
  String res=convertDocument(doc);
  if (res == null) {
    return null;
  }
  return res.getBytes();
}