Program: 115323
Project: 115323
Buggy source:
@Override public void processRequest() throws Exception {
  StudySubjectDAO subdao=new StudySubjectDAO(sm.getDataSource());
  SubjectDAO sdao=new SubjectDAO(sm.getDataSource());
  AuditDAO adao=new AuditDAO(sm.getDataSource());
  FormProcessor fp=new FormProcessor(request);
  StudyEventDAO sedao=new StudyEventDAO(sm.getDataSource());
  StudyEventDefinitionDAO seddao=new StudyEventDefinitionDAO(sm.getDataSource());
  EventDefinitionCRFDAO edcdao=new EventDefinitionCRFDAO(sm.getDataSource());
  EventCRFDAO ecdao=new EventCRFDAO(sm.getDataSource());
  StudyDAO studydao=new StudyDAO(sm.getDataSource());
  CRFDAO cdao=new CRFDAO(sm.getDataSource());
  CRFVersionDAO cvdao=new CRFVersionDAO(sm.getDataSource());
  ArrayList studySubjectAudits=new ArrayList();
  ArrayList eventCRFAudits=new ArrayList();
  ArrayList studyEventAudits=new ArrayList();
  ArrayList allDeletedEventCRFs=new ArrayList();
  String attachedFilePath=Utils.getAttachedFilePath(currentStudy);
  int studySubId=fp.getInt("String_Node_Str",true);
  if (studySubId == 0) {
    addPageMessage(respage.getString("String_Node_Str"));
    forwardPage(Page.LIST_STUDY_SUBJECTS);
  }
 else {
    StudySubjectBean studySubject=(StudySubjectBean)subdao.findByPK(studySubId);
    request.setAttribute("String_Node_Str",studySubject);
    SubjectBean subject=(SubjectBean)sdao.findByPK(studySubject.getSubjectId());
    request.setAttribute("String_Node_Str",subject);
    StudyBean study=(StudyBean)studydao.findByPK(studySubject.getStudyId());
    request.setAttribute("String_Node_Str",study);
    Collection studySubjectAuditEvents=adao.findStudySubjectAuditEvents(studySubject.getId());
    for (Iterator iterator=studySubjectAuditEvents.iterator(); iterator.hasNext(); ) {
      AuditBean auditBean=(AuditBean)iterator.next();
      if (auditBean.getAuditEventTypeId() == 3) {
        auditBean.setOldValue(Status.get(Integer.parseInt(auditBean.getOldValue())).getName());
        auditBean.setNewValue(Status.get(Integer.parseInt(auditBean.getNewValue())).getName());
      }
    }
    studySubjectAudits.addAll(studySubjectAuditEvents);
    studySubjectAudits.addAll(adao.findSubjectAuditEvents(subject.getId()));
    studySubjectAudits.addAll(adao.findStudySubjectGroupAssignmentAuditEvents(studySubject.getId()));
    request.setAttribute("String_Node_Str",studySubjectAudits);
    ArrayList events=sedao.findAllByStudySubject(studySubject);
    for (int i=0; i < events.size(); i++) {
      StudyEventBean studyEvent=(StudyEventBean)events.get(i);
      studyEvent.setStudyEventDefinition((StudyEventDefinitionBean)seddao.findByPK(studyEvent.getStudyEventDefinitionId()));
      studyEvent.setEventCRFs(ecdao.findAllByStudyEvent(studyEvent));
      List deletedEventCRFs=adao.findDeletedEventCRFsFromAuditEvent(studyEvent.getId());
      allDeletedEventCRFs.addAll(deletedEventCRFs);
      logger.info("String_Node_Str" + deletedEventCRFs.size() + "String_Node_Str");
    }
    for (int i=0; i < events.size(); i++) {
      StudyEventBean studyEvent=(StudyEventBean)events.get(i);
      studyEventAudits.addAll(adao.findStudyEventAuditEvents(studyEvent.getId()));
      ArrayList eventCRFs=studyEvent.getEventCRFs();
      for (int j=0; j < eventCRFs.size(); j++) {
        EventCRFBean eventCRF=(EventCRFBean)eventCRFs.get(j);
        eventCRF.setCrfVersion((CRFVersionBean)cvdao.findByPK(eventCRF.getCRFVersionId()));
        eventCRF.setCrf(cdao.findByVersionId(eventCRF.getCRFVersionId()));
        eventCRFAudits.addAll(adao.findEventCRFAuditEventsWithItemDataType(eventCRF.getId()));
        logger.info("String_Node_Str" + eventCRFAudits.size() + "String_Node_Str"+ eventCRF.getId()+ "String_Node_Str");
      }
    }
    request.setAttribute("String_Node_Str",events);
    request.setAttribute("String_Node_Str",eventCRFAudits);
    request.setAttribute("String_Node_Str",studyEventAudits);
    request.setAttribute("String_Node_Str",allDeletedEventCRFs);
    request.setAttribute("String_Node_Str",attachedFilePath);
    forwardPage(Page.VIEW_STUDY_SUBJECT_AUDIT);
  }
}

Fixed version (ground truth):
@Override public void processRequest() throws Exception {
  StudySubjectDAO subdao=new StudySubjectDAO(sm.getDataSource());
  SubjectDAO sdao=new SubjectDAO(sm.getDataSource());
  AuditDAO adao=new AuditDAO(sm.getDataSource());
  FormProcessor fp=new FormProcessor(request);
  StudyEventDAO sedao=new StudyEventDAO(sm.getDataSource());
  StudyEventDefinitionDAO seddao=new StudyEventDefinitionDAO(sm.getDataSource());
  EventDefinitionCRFDAO edcdao=new EventDefinitionCRFDAO(sm.getDataSource());
  EventCRFDAO ecdao=new EventCRFDAO(sm.getDataSource());
  StudyDAO studydao=new StudyDAO(sm.getDataSource());
  CRFDAO cdao=new CRFDAO(sm.getDataSource());
  CRFVersionDAO cvdao=new CRFVersionDAO(sm.getDataSource());
  ArrayList studySubjectAudits=new ArrayList();
  ArrayList eventCRFAudits=new ArrayList();
  ArrayList studyEventAudits=new ArrayList();
  ArrayList allDeletedEventCRFs=new ArrayList();
  String attachedFilePath=Utils.getAttachedFilePath(currentStudy);
  int studySubId=fp.getInt("String_Node_Str",true);
  if (studySubId == 0) {
    addPageMessage(respage.getString("String_Node_Str"));
    forwardPage(Page.LIST_STUDY_SUBJECTS);
  }
 else {
    StudySubjectBean studySubject=(StudySubjectBean)subdao.findByPK(studySubId);
    request.setAttribute("String_Node_Str",studySubject);
    SubjectBean subject=(SubjectBean)sdao.findByPK(studySubject.getSubjectId());
    request.setAttribute("String_Node_Str",subject);
    StudyBean study=(StudyBean)studydao.findByPK(studySubject.getStudyId());
    request.setAttribute("String_Node_Str",study);
    Collection studySubjectAuditEvents=adao.findStudySubjectAuditEvents(studySubject.getId());
    for (Iterator iterator=studySubjectAuditEvents.iterator(); iterator.hasNext(); ) {
      AuditBean auditBean=(AuditBean)iterator.next();
      if (auditBean.getAuditEventTypeId() == 3) {
        auditBean.setOldValue(Status.get(Integer.parseInt(auditBean.getOldValue())).getName());
        auditBean.setNewValue(Status.get(Integer.parseInt(auditBean.getNewValue())).getName());
      }
    }
    studySubjectAudits.addAll(studySubjectAuditEvents);
    studySubjectAudits.addAll(adao.findSubjectAuditEvents(subject.getId()));
    studySubjectAudits.addAll(adao.findStudySubjectGroupAssignmentAuditEvents(studySubject.getId()));
    request.setAttribute("String_Node_Str",studySubjectAudits);
    ArrayList events=sedao.findAllByStudySubject(studySubject);
    for (int i=0; i < events.size(); i++) {
      StudyEventBean studyEvent=(StudyEventBean)events.get(i);
      studyEvent.setStudyEventDefinition((StudyEventDefinitionBean)seddao.findByPK(studyEvent.getStudyEventDefinitionId()));
      studyEvent.setEventCRFs(ecdao.findAllByStudyEvent(studyEvent));
      List deletedEventCRFs=adao.findDeletedEventCRFsFromAuditEvent(studyEvent.getId());
      allDeletedEventCRFs.addAll(deletedEventCRFs);
      logger.info("String_Node_Str" + deletedEventCRFs.size() + "String_Node_Str");
    }
    for (int i=0; i < events.size(); i++) {
      StudyEventBean studyEvent=(StudyEventBean)events.get(i);
      studyEventAudits.addAll(adao.findStudyEventAuditEvents(studyEvent.getId()));
      ArrayList eventCRFs=studyEvent.getEventCRFs();
      for (int j=0; j < eventCRFs.size(); j++) {
        EventCRFBean eventCRF=(EventCRFBean)eventCRFs.get(j);
        eventCRF.setCrfVersion((CRFVersionBean)cvdao.findByPK(eventCRF.getCRFVersionId()));
        eventCRF.setCrf(cdao.findByVersionId(eventCRF.getCRFVersionId()));
        eventCRFAudits.addAll(adao.findEventCRFAuditEventsWithItemDataType(eventCRF.getId()));
        logger.info("String_Node_Str" + eventCRFAudits.size() + "String_Node_Str"+ eventCRF.getId()+ "String_Node_Str");
      }
    }
    ItemDataDAO itemDataDao=new ItemDataDAO(sm.getDataSource());
    for (    Object o : eventCRFAudits) {
      AuditBean ab=(AuditBean)o;
      if (ab.getAuditTable().equalsIgnoreCase("String_Node_Str")) {
        ItemDataBean idBean=(ItemDataBean)itemDataDao.findByPK(ab.getEntityId());
        ab.setOrdinal(idBean.getOrdinal());
      }
    }
    request.setAttribute("String_Node_Str",events);
    request.setAttribute("String_Node_Str",eventCRFAudits);
    request.setAttribute("String_Node_Str",studyEventAudits);
    request.setAttribute("String_Node_Str",allDeletedEventCRFs);
    request.setAttribute("String_Node_Str",attachedFilePath);
    forwardPage(Page.VIEW_STUDY_SUBJECT_AUDIT);
  }
}