Program: 104336
Project: 104336
Buggy source:
/** 
 * Process the incoming sip messages
 * @param requestEvent the incoming event holding the message
 * @return whether this message needs further processing(true) or no(false)
 */
public boolean processMessage(RequestEvent requestEvent){
  String content=null;
  Request req=requestEvent.getRequest();
  ContentTypeHeader ctheader=(ContentTypeHeader)req.getHeader(ContentTypeHeader.NAME);
  if (ctheader == null && !ctheader.getContentSubType().equalsIgnoreCase(CONTENT_SUBTYPE))   return true;
  content=new String(req.getRawContent());
  if (content == null || content.length() == 0) {
    sendResponse(requestEvent,Response.BAD_REQUEST);
    return false;
  }
  FromHeader fromHeader=(FromHeader)requestEvent.getRequest().getHeader(FromHeader.NAME);
  if (fromHeader == null) {
    logger.error("String_Node_Str");
    return true;
  }
  Contact from=opSetPersPresence.resolveContactID(fromHeader.getAddress().getURI().toString());
  Document doc=null;
  try {
    doc=opSetPersPresence.convertDocument(content);
  }
 catch (  Exception e) {
  }
  if (doc == null) {
    sendResponse(requestEvent,Response.BAD_REQUEST);
    return false;
  }
  logger.debug("String_Node_Str" + content);
  NodeList stateList=doc.getElementsByTagNameNS(NS_VALUE,STATE_ELEMENT);
  if (stateList.getLength() == 0) {
    logger.error("String_Node_Str");
    sendResponse(requestEvent,Response.BAD_REQUEST);
    return false;
  }
  Node stateNode=stateList.item(0);
  if (stateNode.getNodeType() != Node.ELEMENT_NODE) {
    logger.error("String_Node_Str");
    sendResponse(requestEvent,Response.BAD_REQUEST);
    return false;
  }
  String state=XMLUtils.getText((Element)stateNode);
  if (state == null || state.length() == 0) {
    logger.error("String_Node_Str");
    sendResponse(requestEvent,Response.BAD_REQUEST);
    return false;
  }
  NodeList refreshList=doc.getElementsByTagNameNS(NS_VALUE,REFRESH_ELEMENT);
  int refresh=REFRESH_DEFAULT_TIME;
  if (refreshList.getLength() != 0) {
    Node refreshNode=refreshList.item(0);
    if (refreshNode.getNodeType() == Node.ELEMENT_NODE) {
      String refreshStr=XMLUtils.getText((Element)refreshNode);
      try {
        refresh=Integer.parseInt(refreshStr);
      }
 catch (      Exception e) {
        logger.error("String_Node_Str",e);
      }
    }
  }
  if (state.equals(COMPOSING_STATE_ACTIVE)) {
    TypingTask task=findTypigTask(from);
    if (task == null) {
      task=new TypingTask(from);
      typingTasks.add(task);
    }
 else     task.cancel();
    timer.schedule(task,refresh * 1000);
    fireTypingNotificationsEvent(from,STATE_TYPING);
  }
 else   if (state.equals(COMPOSING_STATE_IDLE)) {
    fireTypingNotificationsEvent(from,STATE_PAUSED);
  }
  sendResponse(requestEvent,Response.OK);
  return false;
}

Fixed version (ground truth):
/** 
 * Process the incoming sip messages
 * @param requestEvent the incoming event holding the message
 * @return whether this message needs further processing(true) or no(false)
 */
public boolean processMessage(RequestEvent requestEvent){
  String content=null;
  Request req=requestEvent.getRequest();
  ContentTypeHeader ctheader=(ContentTypeHeader)req.getHeader(ContentTypeHeader.NAME);
  if (ctheader == null || !ctheader.getContentSubType().equalsIgnoreCase(CONTENT_SUBTYPE))   return true;
  content=new String(req.getRawContent());
  if (content == null || content.length() == 0) {
    sendResponse(requestEvent,Response.BAD_REQUEST);
    return false;
  }
  FromHeader fromHeader=(FromHeader)requestEvent.getRequest().getHeader(FromHeader.NAME);
  if (fromHeader == null) {
    logger.error("String_Node_Str");
    return true;
  }
  Contact from=opSetPersPresence.resolveContactID(fromHeader.getAddress().getURI().toString());
  Document doc=null;
  try {
    doc=opSetPersPresence.convertDocument(content);
  }
 catch (  Exception e) {
  }
  if (doc == null) {
    sendResponse(requestEvent,Response.BAD_REQUEST);
    return false;
  }
  logger.debug("String_Node_Str" + content);
  NodeList stateList=doc.getElementsByTagNameNS(NS_VALUE,STATE_ELEMENT);
  if (stateList.getLength() == 0) {
    logger.error("String_Node_Str");
    sendResponse(requestEvent,Response.BAD_REQUEST);
    return false;
  }
  Node stateNode=stateList.item(0);
  if (stateNode.getNodeType() != Node.ELEMENT_NODE) {
    logger.error("String_Node_Str");
    sendResponse(requestEvent,Response.BAD_REQUEST);
    return false;
  }
  String state=XMLUtils.getText((Element)stateNode);
  if (state == null || state.length() == 0) {
    logger.error("String_Node_Str");
    sendResponse(requestEvent,Response.BAD_REQUEST);
    return false;
  }
  NodeList refreshList=doc.getElementsByTagNameNS(NS_VALUE,REFRESH_ELEMENT);
  int refresh=REFRESH_DEFAULT_TIME;
  if (refreshList.getLength() != 0) {
    Node refreshNode=refreshList.item(0);
    if (refreshNode.getNodeType() == Node.ELEMENT_NODE) {
      String refreshStr=XMLUtils.getText((Element)refreshNode);
      try {
        refresh=Integer.parseInt(refreshStr);
      }
 catch (      Exception e) {
        logger.error("String_Node_Str",e);
      }
    }
  }
  if (state.equals(COMPOSING_STATE_ACTIVE)) {
    TypingTask task=findTypigTask(from);
    if (task == null) {
      task=new TypingTask(from);
      typingTasks.add(task);
    }
 else     task.cancel();
    timer.schedule(task,refresh * 1000);
    fireTypingNotificationsEvent(from,STATE_TYPING);
  }
 else   if (state.equals(COMPOSING_STATE_IDLE)) {
    fireTypingNotificationsEvent(from,STATE_PAUSED);
  }
  sendResponse(requestEvent,Response.OK);
  return false;
}