Program: 115252
Project: 115252
Buggy source:
protected Element invokeInternal(Element requestElement,Document document) throws Exception {
  System.out.println("String_Node_Str");
  SubjectBean finalSubjectBean=new SubjectBean();
  finalSubjectBean.setUniqueIdentifier("String_Node_Str");
  NodeList subjects=requestElement.getElementsByTagNameNS(CONNECTOR_NAMESPACE_V1,"String_Node_Str");
  try {
    if (subjects.getLength() > 0) {
      System.out.println("String_Node_Str" + subjects.getLength());
      for (int i=0; i < subjects.getLength(); i++) {
        Node childNode=subjects.item(i);
        UserAccountBean user=this.getUserAccount();
        Role r=user.getActiveStudyRole();
        if (r != null && (r.equals(Role.COORDINATOR) || r.equals(Role.STUDYDIRECTOR) || r.equals(Role.INVESTIGATOR)|| r.equals(Role.RESEARCHASSISTANT)|| r.equals(Role.ADMIN))) {
        }
 else {
          throw new CCSystemFaultException("String_Node_Str");
        }
        RegisterSubjectBean subjectBean=subjectService.generateSubjectBean(user,childNode,getStudyDao(),getStudyParamValueDao());
        NodeList performedMilestones=requestElement.getElementsByTagNameNS(CONNECTOR_NAMESPACE_V1,"String_Node_Str");
        if (performedMilestones.getLength() > 0) {
          for (int j=0; j < performedMilestones.getLength(); j++) {
            Node milestone=performedMilestones.item(j);
            subjectBean=subjectService.attachStudyIdentifiers(subjectBean,milestone);
          }
        }
        finalSubjectBean=subjectService.generateSubjectBean(subjectBean);
        SubjectBean testSubjectBean=getSubjectDao().findByUniqueIdentifier(subjectBean.getUniqueIdentifier());
        boolean updateMe=false;
        if (testSubjectBean.getId() > 0) {
          if (subjectService.isSubjectIdentical(subjectBean,testSubjectBean)) {
            testSubjectBean.setUpdater(user);
            testSubjectBean.setDobCollected(true);
            testSubjectBean.setStatus(Status.AVAILABLE);
            updateMe=true;
            finalSubjectBean=testSubjectBean;
          }
 else {
            throw new CCBusinessFaultException("String_Node_Str" + subjectBean.getUniqueIdentifier() + "String_Node_Str");
          }
        }
        StudySubjectBean studySubjectBean=subjectService.generateStudySubjectBean(subjectBean,finalSubjectBean,subjectBean.getStudyBean());
        StudySubjectBean testStudySubjectBean=getStudySubjectDao().findByLabelAndStudy(subjectBean.getStudySubjectLabel(),subjectBean.getStudyBean());
        boolean updateStudySubject=false;
        if (testStudySubjectBean.getId() > 0) {
          if (subjectService.isStudySubjectIdentical(subjectBean,finalSubjectBean,testStudySubjectBean,subjectBean.getStudyBean())) {
            testStudySubjectBean.setUpdater(user);
            testStudySubjectBean.setStatus(Status.AVAILABLE);
            updateStudySubject=true;
            studySubjectBean=testStudySubjectBean;
          }
 else {
            throw new CCBusinessFaultException("String_Node_Str" + subjectBean.getStudySubjectLabel() + "String_Node_Str");
          }
        }
        if (updateMe) {
          finalSubjectBean=(SubjectBean)getSubjectDao().update(finalSubjectBean);
        }
 else {
          finalSubjectBean=getSubjectDao().create(finalSubjectBean);
        }
        studySubjectBean.setSubjectId(finalSubjectBean.getId());
        if (updateStudySubject) {
          studySubjectBean=(StudySubjectBean)getStudySubjectDao().update(studySubjectBean);
        }
 else {
          studySubjectBean=getStudySubjectDao().create(studySubjectBean,false);
        }
        System.out.println("String_Node_Str");
      }
    }
    return mapRegisterSubjectConfirmation(finalSubjectBean.getUniqueIdentifier());
  }
 catch (  Exception npe) {
    npe.printStackTrace();
    if (npe.getClass().getName().startsWith("String_Node_Str")) {
      System.out.println("String_Node_Str" + npe.getClass().getName());
      OpenClinicaException ope=(OpenClinicaException)npe;
      return mapSubjectErrorConfirmation("String_Node_Str",ope);
    }
 else {
      System.out.println("String_Node_Str" + npe.getClass().getName());
      return mapSubjectErrorConfirmation(npe.getMessage());
    }
  }
}

Fixed version (ground truth):
protected Element invokeInternal(Element requestElement,Document document) throws Exception {
  System.out.println("String_Node_Str");
  SubjectBean finalSubjectBean=new SubjectBean();
  finalSubjectBean.setUniqueIdentifier("String_Node_Str");
  NodeList subjects=requestElement.getElementsByTagNameNS(CONNECTOR_NAMESPACE_V1,"String_Node_Str");
  try {
    if (subjects.getLength() > 0) {
      System.out.println("String_Node_Str" + subjects.getLength());
      for (int i=0; i < subjects.getLength(); i++) {
        Node childNode=subjects.item(i);
        UserAccountBean user=this.getUserAccount();
        Role r=user.getActiveStudyRole();
        if (r != null && (r.equals(Role.COORDINATOR) || r.equals(Role.STUDYDIRECTOR) || r.equals(Role.INVESTIGATOR)|| r.equals(Role.RESEARCHASSISTANT)|| r.equals(Role.ADMIN))) {
        }
 else {
          throw new CCSystemFaultException("String_Node_Str");
        }
        RegisterSubjectBean subjectBean=subjectService.generateSubjectBean(user,childNode,getStudyDao(),getStudyParamValueDao());
        NodeList performedMilestones=requestElement.getElementsByTagNameNS(CONNECTOR_NAMESPACE_V1,"String_Node_Str");
        if (performedMilestones.getLength() > 0) {
          for (int j=0; j < performedMilestones.getLength(); j++) {
            Node milestone=performedMilestones.item(j);
            subjectBean=subjectService.attachStudyIdentifiers(subjectBean,milestone);
          }
        }
        finalSubjectBean=subjectService.generateSubjectBean(subjectBean);
        SubjectBean testSubjectBean=getSubjectDao().findByUniqueIdentifier(subjectBean.getUniqueIdentifier());
        boolean updateMe=false;
        if (testSubjectBean.getId() > 0) {
          if (subjectService.isSubjectIdentical(subjectBean,testSubjectBean)) {
            testSubjectBean.setUpdater(user);
            if (finalSubjectBean.getDateOfBirth() != null) {
              testSubjectBean.setDobCollected(true);
              testSubjectBean.setDateOfBirth(finalSubjectBean.getDateOfBirth());
            }
            testSubjectBean.setStatus(Status.AVAILABLE);
            updateMe=true;
            finalSubjectBean=testSubjectBean;
          }
 else {
            throw new CCBusinessFaultException("String_Node_Str" + subjectBean.getUniqueIdentifier() + "String_Node_Str");
          }
        }
        StudySubjectBean studySubjectBean=subjectService.generateStudySubjectBean(subjectBean,finalSubjectBean,subjectBean.getStudyBean());
        StudySubjectBean testStudySubjectBean=getStudySubjectDao().findByLabelAndStudy(subjectBean.getStudySubjectLabel(),subjectBean.getStudyBean());
        boolean updateStudySubject=false;
        if (testStudySubjectBean.getId() > 0) {
          if (subjectService.isStudySubjectIdentical(subjectBean,finalSubjectBean,testStudySubjectBean,subjectBean.getStudyBean())) {
            testStudySubjectBean.setUpdater(user);
            testStudySubjectBean.setStatus(Status.AVAILABLE);
            updateStudySubject=true;
            studySubjectBean=testStudySubjectBean;
          }
 else {
            throw new CCBusinessFaultException("String_Node_Str" + subjectBean.getStudySubjectLabel() + "String_Node_Str");
          }
        }
        if (updateMe) {
          finalSubjectBean=(SubjectBean)getSubjectDao().update(finalSubjectBean);
        }
 else {
          finalSubjectBean=getSubjectDao().create(finalSubjectBean);
        }
        studySubjectBean.setSubjectId(finalSubjectBean.getId());
        if (updateStudySubject) {
          studySubjectBean=(StudySubjectBean)getStudySubjectDao().update(studySubjectBean);
        }
 else {
          studySubjectBean=getStudySubjectDao().create(studySubjectBean,false);
        }
        System.out.println("String_Node_Str");
      }
    }
    return mapRegisterSubjectConfirmation(finalSubjectBean.getUniqueIdentifier());
  }
 catch (  Exception npe) {
    npe.printStackTrace();
    if (npe.getClass().getName().startsWith("String_Node_Str")) {
      System.out.println("String_Node_Str" + npe.getClass().getName());
      OpenClinicaException ope=(OpenClinicaException)npe;
      return mapSubjectErrorConfirmation("String_Node_Str",ope);
    }
 else {
      System.out.println("String_Node_Str" + npe.getClass().getName());
      return mapSubjectErrorConfirmation(npe.getMessage());
    }
  }
}