Program: 146972
Project: 146972
Buggy source:
public PatientReferral parse() throws InvalidStructureException, IOException, XmlPullParserException {
  this.checkNode("String_Node_Str");
  this.nextTag("String_Node_Str");
  String refId=parser.nextText().trim();
  while (this.nextTagInBlock("String_Node_Str")) {
    String action=parser.getName().toLowerCase();
    Date followup=created;
    if (action.equals("String_Node_Str")) {
      String followupDate=parser.nextText();
      followup=DateUtils.parseDate(followupDate);
    }
    if (action.equals("String_Node_Str")) {
      this.getNextTagInBlock("String_Node_Str");
      checkNode("String_Node_Str");
      String referralTypes=parser.nextText();
      for (      Object s : DateUtils.split(referralTypes,"String_Node_Str",true)) {
        PatientReferral pr=new PatientReferral((String)s,created,refId,caseId,followup);
        commit(pr);
        Logger.log("String_Node_Str",pr.getID() + "String_Node_Str" + PropertyUtils.trim(pr.getReferralId(),12)+ "String_Node_Str"+ pr.getType());
      }
      if (this.nextTagInBlock("String_Node_Str")) {
        throw new InvalidStructureException("String_Node_Str" + parser.getName(),parser);
      }
    }
 else     if (action.equals("String_Node_Str")) {
      this.getNextTagInBlock("String_Node_Str");
      checkNode("String_Node_Str");
      String refType=parser.nextText().trim();
      PatientReferral r=retrieve(refId,refType);
      if (r == null) {
        throw new InvalidStructureException("String_Node_Str" + refId,parser);
      }
      r.setDateDue(followup);
      if (this.nextTagInBlock("String_Node_Str")) {
        String dateClosed=parser.nextText();
        r.close();
        commit(r);
        Logger.log("String_Node_Str",PropertyUtils.trim(r.getReferralId(),12) + "String_Node_Str" + r.getType());
        if (this.nextTagInBlock("String_Node_Str")) {
          throw new InvalidStructureException("String_Node_Str" + parser.getName(),parser);
        }
      }
    }
  }
  return null;
}

Fixed version (ground truth):
public PatientReferral parse() throws InvalidStructureException, IOException, XmlPullParserException {
  this.checkNode("String_Node_Str");
  this.nextTag("String_Node_Str");
  String refId=parser.nextText().trim();
  while (this.nextTagInBlock("String_Node_Str")) {
    String action=parser.getName().toLowerCase();
    Date followup=created;
    if (action.equals("String_Node_Str")) {
      String followupDate=parser.nextText();
      followup=DateUtils.parseDate(followupDate);
    }
    if (action.equals("String_Node_Str")) {
      this.getNextTagInBlock("String_Node_Str");
      checkNode("String_Node_Str");
      String referralTypes=parser.nextText();
      for (      Object s : DateUtils.split(referralTypes,"String_Node_Str",true)) {
        PatientReferral pr=new PatientReferral((String)s,created,refId,caseId,followup);
        boolean overriden=false;
        if (acceptCreateOverwrites) {
          PatientReferral old=retrieve(refId,(String)s);
          if (old != null) {
            pr.setID(old.getID());
            overriden=true;
          }
        }
        commit(pr);
        String succesfulAction=overriden ? "String_Node_Str" : "String_Node_Str";
        Logger.log(succesfulAction,pr.getID() + "String_Node_Str" + PropertyUtils.trim(pr.getReferralId(),12)+ "String_Node_Str"+ pr.getType());
      }
      if (this.nextTagInBlock("String_Node_Str")) {
        throw new InvalidStructureException("String_Node_Str" + parser.getName(),parser);
      }
    }
 else     if (action.equals("String_Node_Str")) {
      this.getNextTagInBlock("String_Node_Str");
      checkNode("String_Node_Str");
      String refType=parser.nextText().trim();
      PatientReferral r=retrieve(refId,refType);
      if (r == null) {
        throw new InvalidStructureException("String_Node_Str" + refId,parser);
      }
      r.setDateDue(followup);
      if (this.nextTagInBlock("String_Node_Str")) {
        String dateClosed=parser.nextText();
        r.close();
        commit(r);
        Logger.log("String_Node_Str",PropertyUtils.trim(r.getReferralId(),12) + "String_Node_Str" + r.getType());
        if (this.nextTagInBlock("String_Node_Str")) {
          throw new InvalidStructureException("String_Node_Str" + parser.getName(),parser);
        }
      }
    }
  }
  return null;
}