Program: 181547
Project: 181547
Buggy source:
/** 
 * Parse the pdu.
 * @return the pdu structure if parsing successfully.null if parsing error happened or mandatory fields are not set.
 */
public GenericPdu parse(){
  if (mPduDataStream == null) {
    return null;
  }
  mHeaders=parseHeaders(mPduDataStream);
  if (null == mHeaders) {
    return null;
  }
  int messageType=mHeaders.getOctet(PduHeaders.MESSAGE_TYPE);
  if (false == checkMandatoryHeader(mHeaders)) {
    log("String_Node_Str");
    return null;
  }
  if ((PduHeaders.MESSAGE_TYPE_SEND_REQ == messageType) || (PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF == messageType)) {
    mBody=parseParts(mPduDataStream);
    if (null == mBody) {
      return null;
    }
  }
switch (messageType) {
case PduHeaders.MESSAGE_TYPE_SEND_REQ:
    SendReq sendReq=new SendReq(mHeaders,mBody);
  return sendReq;
case PduHeaders.MESSAGE_TYPE_SEND_CONF:
SendConf sendConf=new SendConf(mHeaders);
return sendConf;
case PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND:
NotificationInd notificationInd=new NotificationInd(mHeaders);
return notificationInd;
case PduHeaders.MESSAGE_TYPE_NOTIFYRESP_IND:
NotifyRespInd notifyRespInd=new NotifyRespInd(mHeaders);
return notifyRespInd;
case PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF:
RetrieveConf retrieveConf=new RetrieveConf(mHeaders,mBody);
byte[] contentType=retrieveConf.getContentType();
if (null == contentType) {
return null;
}
String ctTypeStr=new String(contentType);
if (ctTypeStr.equals(ContentType.MULTIPART_MIXED) || ctTypeStr.equals(ContentType.MULTIPART_RELATED)) {
return retrieveConf;
}
return null;
case PduHeaders.MESSAGE_TYPE_DELIVERY_IND:
DeliveryInd deliveryInd=new DeliveryInd(mHeaders);
return deliveryInd;
case PduHeaders.MESSAGE_TYPE_ACKNOWLEDGE_IND:
AcknowledgeInd acknowledgeInd=new AcknowledgeInd(mHeaders);
return acknowledgeInd;
case PduHeaders.MESSAGE_TYPE_READ_ORIG_IND:
ReadOrigInd readOrigInd=new ReadOrigInd(mHeaders);
return readOrigInd;
case PduHeaders.MESSAGE_TYPE_READ_REC_IND:
ReadRecInd readRecInd=new ReadRecInd(mHeaders);
return readRecInd;
default :
log("String_Node_Str");
return null;
}
}

Fixed version (ground truth):
/** 
 * Parse the pdu.
 * @return the pdu structure if parsing successfully.null if parsing error happened or mandatory fields are not set.
 */
public GenericPdu parse(){
  if (mPduDataStream == null) {
    return null;
  }
  mHeaders=parseHeaders(mPduDataStream);
  if (null == mHeaders) {
    return null;
  }
  int messageType=mHeaders.getOctet(PduHeaders.MESSAGE_TYPE);
  if (false == checkMandatoryHeader(mHeaders)) {
    log("String_Node_Str");
    return null;
  }
  if ((PduHeaders.MESSAGE_TYPE_SEND_REQ == messageType) || (PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF == messageType)) {
    mBody=parseParts(mPduDataStream);
    if (null == mBody) {
      return null;
    }
  }
switch (messageType) {
case PduHeaders.MESSAGE_TYPE_SEND_REQ:
    SendReq sendReq=new SendReq(mHeaders,mBody);
  return sendReq;
case PduHeaders.MESSAGE_TYPE_SEND_CONF:
SendConf sendConf=new SendConf(mHeaders);
return sendConf;
case PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND:
NotificationInd notificationInd=new NotificationInd(mHeaders);
return notificationInd;
case PduHeaders.MESSAGE_TYPE_NOTIFYRESP_IND:
NotifyRespInd notifyRespInd=new NotifyRespInd(mHeaders);
return notifyRespInd;
case PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF:
RetrieveConf retrieveConf=new RetrieveConf(mHeaders,mBody);
byte[] contentType=retrieveConf.getContentType();
if (null == contentType) {
return null;
}
String ctTypeStr=new String(contentType);
if (ctTypeStr.equals(ContentType.MULTIPART_MIXED) || ctTypeStr.equals(ContentType.MULTIPART_RELATED) || ctTypeStr.equals(ContentType.MULTIPART_ALTERNATIVE)) {
return retrieveConf;
}
return null;
case PduHeaders.MESSAGE_TYPE_DELIVERY_IND:
DeliveryInd deliveryInd=new DeliveryInd(mHeaders);
return deliveryInd;
case PduHeaders.MESSAGE_TYPE_ACKNOWLEDGE_IND:
AcknowledgeInd acknowledgeInd=new AcknowledgeInd(mHeaders);
return acknowledgeInd;
case PduHeaders.MESSAGE_TYPE_READ_ORIG_IND:
ReadOrigInd readOrigInd=new ReadOrigInd(mHeaders);
return readOrigInd;
case PduHeaders.MESSAGE_TYPE_READ_REC_IND:
ReadRecInd readRecInd=new ReadRecInd(mHeaders);
return readRecInd;
default :
log("String_Node_Str");
return null;
}
}