Program: 115181
Project: 115181
Buggy source:
@Override protected void processRequest() throws Exception {
  FormProcessor fp=new FormProcessor(request);
  int noteId=fp.getInt(INPUT_NOTE_ID);
  String module=(String)session.getAttribute("String_Node_Str");
  StudySubjectDAO studySubjectDAO=new StudySubjectDAO(sm.getDataSource());
  DiscrepancyNoteDAO dndao=new DiscrepancyNoteDAO(sm.getDataSource());
  dndao.setFetchMapping(true);
  DiscrepancyNoteBean discrepancyNoteBean=(DiscrepancyNoteBean)dndao.findByPK(noteId);
  if (!discrepancyNoteBean.isActive()) {
    throw new InconsistentStateException(Page.MANAGE_STUDY_SERVLET,resexception.getString("String_Node_Str"));
  }
  ArrayList children=dndao.findAllByParent(discrepancyNoteBean);
  discrepancyNoteBean.setChildren(children);
  if (parentNoteIsClosed(discrepancyNoteBean)) {
    throw new InconsistentStateException(Page.VIEW_DISCREPANCY_NOTES_IN_STUDY_SERVLET,respage.getString("String_Node_Str"));
  }
  String entityType=discrepancyNoteBean.getEntityType().toLowerCase();
  discrepancyNoteBean.setResStatus(ResolutionStatus.get(discrepancyNoteBean.getResolutionStatusId()));
  discrepancyNoteBean.setDisType(DiscrepancyNoteType.get(discrepancyNoteBean.getDiscrepancyNoteTypeId()));
  if (currentRole.getRole().equals(Role.MONITOR) && !"String_Node_Str".equalsIgnoreCase(entityType) && !"String_Node_Str".equalsIgnoreCase(entityType)) {
    redirectMonitor(module,discrepancyNoteBean);
    return;
  }
  if (currentStudy.getStatus().isFrozen()) {
    redirectMonitor(module,discrepancyNoteBean);
    return;
  }
  boolean toView=false;
  boolean isCompleted=false;
  if ("String_Node_Str".equalsIgnoreCase(entityType)) {
    ItemDataDAO iddao=new ItemDataDAO(sm.getDataSource());
    ItemDataBean idb=(ItemDataBean)iddao.findByPK(discrepancyNoteBean.getEntityId());
    EventCRFDAO ecdao=new EventCRFDAO(sm.getDataSource());
    EventCRFBean ecb=(EventCRFBean)ecdao.findByPK(idb.getEventCRFId());
    StudySubjectBean studySubjectBean=(StudySubjectBean)studySubjectDAO.findByPK(ecb.getStudySubjectId());
    discrepancyNoteBean.setSubjectId(studySubjectBean.getId());
    discrepancyNoteBean.setItemId(idb.getItemId());
    if (ecb.getStatus().equals(Status.UNAVAILABLE)) {
      isCompleted=true;
    }
    toView=true;
  }
  boolean goNext=prepareRequestForResolution(request,sm.getDataSource(),currentStudy,discrepancyNoteBean,isCompleted);
  Page p=getPageForForwarding(discrepancyNoteBean,isCompleted);
  if (p == null) {
    throw new InconsistentStateException(Page.VIEW_DISCREPANCY_NOTES_IN_STUDY_SERVLET,resexception.getString("String_Node_Str"));
  }
 else {
    if (p.getFileName().contains("String_Node_Str")) {
      if (!p.getFileName().contains("String_Node_Str")) {
        p.setFileName(p.getFileName() + "String_Node_Str");
      }
    }
 else {
      p.setFileName(p.getFileName() + "String_Node_Str");
    }
    String createNoteURL=CreateDiscrepancyNoteServlet.getAddChildURL(discrepancyNoteBean,ResolutionStatus.CLOSED,true);
    setPopUpURL(createNoteURL);
  }
  if (!goNext) {
    setPopUpURL("String_Node_Str");
    addPageMessage(respage.getString("String_Node_Str"));
    p=Page.VIEW_DISCREPANCY_NOTES_IN_STUDY_SERVLET;
  }
  forwardPage(p);
}

Fixed version (ground truth):
@Override protected void processRequest() throws Exception {
  FormProcessor fp=new FormProcessor(request);
  int noteId=fp.getInt(INPUT_NOTE_ID);
  String module=(String)session.getAttribute("String_Node_Str");
  StudySubjectDAO studySubjectDAO=new StudySubjectDAO(sm.getDataSource());
  DiscrepancyNoteDAO dndao=new DiscrepancyNoteDAO(sm.getDataSource());
  dndao.setFetchMapping(true);
  DiscrepancyNoteBean discrepancyNoteBean=(DiscrepancyNoteBean)dndao.findByPK(noteId);
  if (!discrepancyNoteBean.isActive()) {
    throw new InconsistentStateException(Page.MANAGE_STUDY_SERVLET,resexception.getString("String_Node_Str"));
  }
  ArrayList children=dndao.findAllByParent(discrepancyNoteBean);
  discrepancyNoteBean.setChildren(children);
  String entityType=discrepancyNoteBean.getEntityType().toLowerCase();
  discrepancyNoteBean.setResStatus(ResolutionStatus.get(discrepancyNoteBean.getResolutionStatusId()));
  discrepancyNoteBean.setDisType(DiscrepancyNoteType.get(discrepancyNoteBean.getDiscrepancyNoteTypeId()));
  if (currentRole.getRole().equals(Role.MONITOR) && !"String_Node_Str".equalsIgnoreCase(entityType) && !"String_Node_Str".equalsIgnoreCase(entityType)) {
    redirectMonitor(module,discrepancyNoteBean);
    return;
  }
  if (currentStudy.getStatus().isFrozen()) {
    redirectMonitor(module,discrepancyNoteBean);
    return;
  }
  boolean toView=false;
  boolean isCompleted=false;
  if ("String_Node_Str".equalsIgnoreCase(entityType)) {
    ItemDataDAO iddao=new ItemDataDAO(sm.getDataSource());
    ItemDataBean idb=(ItemDataBean)iddao.findByPK(discrepancyNoteBean.getEntityId());
    EventCRFDAO ecdao=new EventCRFDAO(sm.getDataSource());
    EventCRFBean ecb=(EventCRFBean)ecdao.findByPK(idb.getEventCRFId());
    StudySubjectBean studySubjectBean=(StudySubjectBean)studySubjectDAO.findByPK(ecb.getStudySubjectId());
    discrepancyNoteBean.setSubjectId(studySubjectBean.getId());
    discrepancyNoteBean.setItemId(idb.getItemId());
    if (ecb.getStatus().equals(Status.UNAVAILABLE)) {
      isCompleted=true;
    }
    toView=true;
  }
  boolean goNext=prepareRequestForResolution(request,sm.getDataSource(),currentStudy,discrepancyNoteBean,isCompleted);
  Page p=getPageForForwarding(discrepancyNoteBean,isCompleted);
  if (p == null) {
    throw new InconsistentStateException(Page.VIEW_DISCREPANCY_NOTES_IN_STUDY_SERVLET,resexception.getString("String_Node_Str"));
  }
 else {
    if (p.getFileName().contains("String_Node_Str")) {
      if (!p.getFileName().contains("String_Node_Str")) {
        p.setFileName(p.getFileName() + "String_Node_Str");
      }
    }
 else {
      p.setFileName(p.getFileName() + "String_Node_Str");
    }
    String createNoteURL=CreateDiscrepancyNoteServlet.getAddChildURL(discrepancyNoteBean,ResolutionStatus.CLOSED,true);
    setPopUpURL(createNoteURL);
  }
  if (!goNext) {
    setPopUpURL("String_Node_Str");
    addPageMessage(respage.getString("String_Node_Str"));
    p=Page.VIEW_DISCREPANCY_NOTES_IN_STUDY_SERVLET;
  }
  forwardPage(p);
}