Program: 115108
Project: 115108
Buggy source:
protected List<DisplayItemWithGroupBean> createItemWithGroups(DisplaySectionBean dsb,boolean hasItemGroup,int eventCRFDefId,HttpServletRequest request){
  HttpSession session=request.getSession();
  List<DisplayItemWithGroupBean> displayItemWithGroups=new ArrayList<DisplayItemWithGroupBean>();
  EventCRFBean ecb=(EventCRFBean)request.getAttribute(INPUT_EVENT_CRF);
  ItemDAO idao=new ItemDAO(getDataSource());
  FormBeanUtil formBeanUtil=new FormBeanUtil();
  SectionBean sb=(SectionBean)request.getAttribute(SECTION_BEAN);
  EventDefinitionCRFBean edcb=(EventDefinitionCRFBean)request.getAttribute(EVENT_DEF_CRF_BEAN);
  ArrayList items=dsb.getItems();
  logger.trace("String_Node_Str" + items.size());
  for (int i=0; i < items.size(); i++) {
    DisplayItemBean item=(DisplayItemBean)items.get(i);
    DisplayItemWithGroupBean newOne=new DisplayItemWithGroupBean();
    newOne.setSingleItem(runDynamicsItemCheck(item,null,request));
    newOne.setOrdinal(item.getMetadata().getOrdinal());
    newOne.setInGroup(false);
    newOne.setPageNumberLabel(item.getMetadata().getPageNumberLabel());
    displayItemWithGroups.add(newOne);
  }
  if (hasItemGroup) {
    ItemDataDAO iddao=new ItemDataDAO(getDataSource(),locale);
    HashMap<String,ItemDataBean> dataMap=(HashMap<String,ItemDataBean>)iddao.findAllActiveMap(sb.getId(),ecb.getId());
    ArrayList<ItemDataBean> data=iddao.findAllActiveBySectionIdAndEventCRFId(sb.getId(),ecb.getId());
    if (data != null && data.size() > 0) {
      session.setAttribute(HAS_DATA_FLAG,true);
    }
    logger.trace("String_Node_Str" + data.size());
    logger.trace("String_Node_Str" + data.toString());
    for (    DisplayItemGroupBean itemGroup : dsb.getDisplayFormGroups()) {
      logger.debug("String_Node_Str");
      DisplayItemWithGroupBean newOne=new DisplayItemWithGroupBean();
      DisplayItemBean firstItem=itemGroup.getItems().get(0);
      newOne.setPageNumberLabel(firstItem.getMetadata().getPageNumberLabel());
      newOne.setItemGroup(itemGroup);
      newOne.setInGroup(true);
      newOne.setOrdinal(itemGroup.getGroupMetaBean().getOrdinal());
      List<ItemBean> itBeans=idao.findAllItemsByGroupIdOrdered(itemGroup.getItemGroupBean().getId(),sb.getCRFVersionId());
      List<DisplayItemBean> dibs=new ArrayList();
      DisplayItemGroupBean digb=new DisplayItemGroupBean();
      boolean hasData=false;
      int checkAllColumns=0;
      if (data.size() > 0)       hasData=true;
      newOne=buildMatrixForRepeatingGroups(newOne,itemGroup,ecb,sb,itBeans,dataMap);
      if (hasData) {
        session.setAttribute(GROUP_HAS_DATA,Boolean.TRUE);
      }
 else {
        session.setAttribute(GROUP_HAS_DATA,Boolean.FALSE);
        DisplayItemGroupBean digb2=new DisplayItemGroupBean();
        digb2.setItems(dibs);
        digb2.setEditFlag("String_Node_Str");
      }
      displayItemWithGroups.add(newOne);
    }
  }
  return displayItemWithGroups;
}

Fixed version (ground truth):
protected List<DisplayItemWithGroupBean> createItemWithGroups(DisplaySectionBean dsb,boolean hasItemGroup,int eventCRFDefId,HttpServletRequest request){
  HttpSession session=request.getSession();
  List<DisplayItemWithGroupBean> displayItemWithGroups=new ArrayList<DisplayItemWithGroupBean>();
  EventCRFBean ecb=(EventCRFBean)request.getAttribute(INPUT_EVENT_CRF);
  ItemDAO idao=new ItemDAO(getDataSource());
  SectionBean sb=(SectionBean)request.getAttribute(SECTION_BEAN);
  EventDefinitionCRFBean edcb=(EventDefinitionCRFBean)request.getAttribute(EVENT_DEF_CRF_BEAN);
  ArrayList items=dsb.getItems();
  logger.trace("String_Node_Str" + items.size());
  for (int i=0; i < items.size(); i++) {
    DisplayItemBean item=(DisplayItemBean)items.get(i);
    DisplayItemWithGroupBean newOne=new DisplayItemWithGroupBean();
    newOne.setSingleItem(runDynamicsItemCheck(item,null,request));
    newOne.setOrdinal(item.getMetadata().getOrdinal());
    newOne.setInGroup(false);
    newOne.setPageNumberLabel(item.getMetadata().getPageNumberLabel());
    displayItemWithGroups.add(newOne);
  }
  if (hasItemGroup) {
    ItemDataDAO iddao=new ItemDataDAO(getDataSource(),locale);
    ArrayList<ItemDataBean> data=iddao.findAllActiveBySectionIdAndEventCRFId(sb.getId(),ecb.getId());
    HashMap<String,ItemDataBean> dataMap=(HashMap<String,ItemDataBean>)getAllActive(data);
    if (data != null && data.size() > 0) {
      session.setAttribute(HAS_DATA_FLAG,true);
    }
    logger.trace("String_Node_Str" + data.size());
    logger.trace("String_Node_Str" + data.toString());
    for (    DisplayItemGroupBean itemGroup : dsb.getDisplayFormGroups()) {
      logger.debug("String_Node_Str");
      DisplayItemWithGroupBean newOne=new DisplayItemWithGroupBean();
      DisplayItemBean firstItem=itemGroup.getItems().get(0);
      newOne.setPageNumberLabel(firstItem.getMetadata().getPageNumberLabel());
      newOne.setItemGroup(itemGroup);
      newOne.setInGroup(true);
      newOne.setOrdinal(itemGroup.getGroupMetaBean().getOrdinal());
      List<ItemBean> itBeans=idao.findAllItemsByGroupIdOrdered(itemGroup.getItemGroupBean().getId(),sb.getCRFVersionId());
      List<DisplayItemBean> dibs=new ArrayList();
      DisplayItemGroupBean digb=new DisplayItemGroupBean();
      boolean hasData=false;
      int checkAllColumns=0;
      if (data.size() > 0)       hasData=true;
      newOne=buildMatrixForRepeatingGroups(newOne,itemGroup,ecb,sb,itBeans,dataMap);
      if (hasData) {
        session.setAttribute(GROUP_HAS_DATA,Boolean.TRUE);
      }
 else {
        session.setAttribute(GROUP_HAS_DATA,Boolean.FALSE);
        DisplayItemGroupBean digb2=new DisplayItemGroupBean();
        digb2.setItems(dibs);
        digb2.setEditFlag("String_Node_Str");
      }
      displayItemWithGroups.add(newOne);
    }
  }
  return displayItemWithGroups;
}