Program: 115272
Project: 115272
Buggy source:
@Override public void processRequest() throws Exception {
  FormProcessor fp=new FormProcessor(request);
  int versionId=fp.getInt(VERSION_ID,true);
  String action=request.getParameter("String_Node_Str");
  if (versionId == 0) {
    addPageMessage(respage.getString("String_Node_Str"));
    forwardPage(Page.CRF_LIST_SERVLET);
  }
 else {
    CRFVersionDAO cvdao=new CRFVersionDAO(sm.getDataSource());
    CRFVersionBean version=(CRFVersionBean)cvdao.findByPK(versionId);
    EventDefinitionCRFDAO edcdao=new EventDefinitionCRFDAO(sm.getDataSource());
    ArrayList definitions=edcdao.findByDefaultVersion(version.getId());
    EventCRFDAO ecdao=new EventCRFDAO(sm.getDataSource());
    ArrayList eventCRFs=ecdao.findAllByCRFVersion(versionId);
    boolean canDelete=true;
    if (!definitions.isEmpty()) {
      canDelete=false;
      request.setAttribute("String_Node_Str",definitions);
      addPageMessage(respage.getString("String_Node_Str") + version.getName() + respage.getString("String_Node_Str"));
    }
 else     if (!eventCRFs.isEmpty()) {
      canDelete=false;
      request.setAttribute("String_Node_Str",eventCRFs);
      addPageMessage(respage.getString("String_Node_Str") + version.getName() + respage.getString("String_Node_Str"));
    }
    if ("String_Node_Str".equalsIgnoreCase(action)) {
      request.setAttribute(VERSION_TO_DELETE,version);
      forwardPage(Page.DELETE_CRF_VERSION);
    }
 else {
      if (canDelete) {
        ArrayList items=cvdao.findNotSharedItemsByVersion(versionId);
        NewCRFBean nib=new NewCRFBean(sm.getDataSource(),version.getCrfId());
        nib.setDeleteQueries(cvdao.generateDeleteQueries(versionId,items));
        nib.deleteFromDB();
        addPageMessage(respage.getString("String_Node_Str"));
      }
 else {
        addPageMessage(respage.getString("String_Node_Str"));
      }
      forwardPage(Page.CRF_LIST_SERVLET);
    }
  }
}

Fixed version (ground truth):
@Override public void processRequest() throws Exception {
  FormProcessor fp=new FormProcessor(request);
  int versionId=fp.getInt(VERSION_ID,true);
  String action=request.getParameter("String_Node_Str");
  if (versionId == 0) {
    addPageMessage(respage.getString("String_Node_Str"));
    forwardPage(Page.CRF_LIST_SERVLET);
  }
 else {
    CRFVersionDAO cvdao=new CRFVersionDAO(sm.getDataSource());
    CRFVersionBean version=(CRFVersionBean)cvdao.findByPK(versionId);
    EventDefinitionCRFDAO edcdao=new EventDefinitionCRFDAO(sm.getDataSource());
    StudyEventDefinitionDAO sedDao=new StudyEventDefinitionDAO(sm.getDataSource());
    ArrayList definitions=edcdao.findByDefaultVersion(version.getId());
    for (    Object edcBean : definitions) {
      StudyEventDefinitionBean sedBean=(StudyEventDefinitionBean)sedDao.findByPK(((EventDefinitionCRFBean)edcBean).getStudyEventDefinitionId());
      ((EventDefinitionCRFBean)edcBean).setEventName(sedBean.getName());
    }
    EventCRFDAO ecdao=new EventCRFDAO(sm.getDataSource());
    ArrayList eventCRFs=ecdao.findAllByCRFVersion(versionId);
    boolean canDelete=true;
    if (!definitions.isEmpty()) {
      canDelete=false;
      request.setAttribute("String_Node_Str",definitions);
      addPageMessage(respage.getString("String_Node_Str") + version.getName() + respage.getString("String_Node_Str"));
    }
 else     if (!eventCRFs.isEmpty()) {
      canDelete=false;
      request.setAttribute("String_Node_Str",eventCRFs);
      addPageMessage(respage.getString("String_Node_Str") + version.getName() + respage.getString("String_Node_Str"));
    }
    if ("String_Node_Str".equalsIgnoreCase(action)) {
      request.setAttribute(VERSION_TO_DELETE,version);
      forwardPage(Page.DELETE_CRF_VERSION);
    }
 else {
      if (canDelete) {
        ArrayList items=cvdao.findNotSharedItemsByVersion(versionId);
        NewCRFBean nib=new NewCRFBean(sm.getDataSource(),version.getCrfId());
        nib.setDeleteQueries(cvdao.generateDeleteQueries(versionId,items));
        nib.deleteFromDB();
        addPageMessage(respage.getString("String_Node_Str"));
      }
 else {
        addPageMessage(respage.getString("String_Node_Str"));
      }
      forwardPage(Page.CRF_LIST_SERVLET);
    }
  }
}