Program: 115096
Project: 115096
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());
  SectionBean sb=(SectionBean)request.getAttribute(SECTION_BEAN);
  EventDefinitionCRFBean edcb=(EventDefinitionCRFBean)request.getAttribute(EVENT_DEF_CRF_BEAN);
  ArrayList items=dsb.getItems();
  FormBeanUtil formBeanUtil=new FormBeanUtil();
  List<String> nullValuesList=formBeanUtil.getNullValuesByEventCRFDefId(eventCRFDefId,getDataSource());
  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();
      boolean hasData=false;
      int checkAllColumns=0;
      if (data.size() > 0)       hasData=true;
      newOne=buildMatrixForRepeatingGroups(newOne,itemGroup,ecb,sb,itBeans,dataMap,nullValuesList);
      if (hasData) {
        session.setAttribute(GROUP_HAS_DATA,Boolean.TRUE);
      }
 else {
        session.setAttribute(GROUP_HAS_DATA,Boolean.FALSE);
        if (nullValuesList != null && nullValuesList.size() > 0) {
          LOGGER.trace("String_Node_Str" + nullValuesList);
        }
        dibs=FormBeanUtil.getDisplayBeansFromItems(itBeans,getDataSource(),ecb,sb.getId(),nullValuesList,getServletContext());
        DisplayItemGroupBean digb2=new DisplayItemGroupBean();
        digb2.setItems(dibs);
        digb2.setEditFlag("String_Node_Str");
      }
      displayItemWithGroups.add(newOne);
    }
  }
  Collections.sort(displayItemWithGroups);
  return displayItemWithGroups;
}

Fixed version (ground truth):
protected List<DisplayItemWithGroupBean> createItemWithGroups(DisplaySectionBean dsb,boolean hasItemGroup,int eventCRFDefId,HttpServletRequest request,boolean isSubmitted){
  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();
  FormBeanUtil formBeanUtil=new FormBeanUtil();
  List<String> nullValuesList=formBeanUtil.getNullValuesByEventCRFDefId(eventCRFDefId,getDataSource());
  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();
      boolean hasData=false;
      int checkAllColumns=0;
      if (data.size() > 0)       hasData=true;
      newOne=buildMatrixForRepeatingGroups(newOne,itemGroup,ecb,sb,itBeans,dataMap,nullValuesList,isSubmitted);
      if (hasData) {
        session.setAttribute(GROUP_HAS_DATA,Boolean.TRUE);
      }
 else {
        session.setAttribute(GROUP_HAS_DATA,Boolean.FALSE);
        if (nullValuesList != null && nullValuesList.size() > 0) {
          LOGGER.trace("String_Node_Str" + nullValuesList);
        }
        dibs=FormBeanUtil.getDisplayBeansFromItems(itBeans,getDataSource(),ecb,sb.getId(),nullValuesList,getServletContext());
        DisplayItemGroupBean digb2=new DisplayItemGroupBean();
        digb2.setItems(dibs);
        digb2.setEditFlag("String_Node_Str");
      }
      displayItemWithGroups.add(newOne);
    }
  }
  Collections.sort(displayItemWithGroups);
  return displayItemWithGroups;
}