Program: 115175
Project: 115175
Buggy source:
@RequestMapping(method=RequestMethod.GET) public ModelMap handleMainPage(HttpServletRequest request){
  ModelMap map=new ModelMap();
  StudyInfoPanel panel=new StudyInfoPanel();
  panel.reset();
  request.getSession().setAttribute("String_Node_Str",panel);
  ResourceBundleProvider.updateLocale(request.getLocale());
  StudyBean currentStudy=(StudyBean)request.getSession().getAttribute("String_Node_Str");
  eventDefinitionCRFDao=new EventDefinitionCRFDAO(dataSource);
  studyEventDefinitionDao=new StudyEventDefinitionDAO(dataSource);
  crfDao=new CRFDAO(dataSource);
  studyGroupClassDao=new StudyGroupClassDAO(dataSource);
  studyDao=new StudyDAO(dataSource);
  userDao=new UserAccountDAO(dataSource);
  ruleDao=new RuleDAO(dataSource);
  StudyModuleStatus sms=studyModuleStatusDao.findByStudyId(currentStudy.getId());
  if (sms == null) {
    sms=new StudyModuleStatus();
    sms.setStudyId(currentStudy.getId());
  }
  int crfCount=crfDao.findAllByStudy(currentStudy.getId()).size();
  int crfWithEventDefinition=crfDao.findAllActiveByDefinitions(currentStudy.getId()).size();
  int totalCrf=crfCount + crfWithEventDefinition;
  int eventDefinitionCount=studyEventDefinitionDao.findAllActiveByStudy(currentStudy).size();
  int subjectGroupCount=studyGroupClassDao.findAllActiveByStudy(currentStudy).size();
  int ruleCount=ruleSetService.getCountByStudy(currentStudy);
  int siteCount=studyDao.findOlnySiteIdsByStudy(currentStudy).size();
  int userCount=userDao.findAllUsersByStudy(currentStudy.getId()).size();
  Collection childStudies=studyDao.findAllByParent(currentStudy.getId());
  Map childStudyUserCount=new HashMap();
  for (  Object sb : childStudies) {
    StudyBean childStudy=(StudyBean)sb;
    childStudyUserCount.put(childStudy.getName(),userDao.findAllUsersByStudy(childStudy.getId()).size());
  }
  if (sms.getCrf() == 0) {
    sms.setCrf(StudyModuleStatus.NOT_STARTED);
  }
  if (sms.getCrf() != 3 && totalCrf > 0) {
    sms.setCrf(StudyModuleStatus.IN_PROGRESS);
  }
  if (sms.getEventDefinition() == 0) {
    sms.setEventDefinition(StudyModuleStatus.NOT_STARTED);
  }
  if (sms.getEventDefinition() != 3 && eventDefinitionCount > 0) {
    sms.setEventDefinition(StudyModuleStatus.IN_PROGRESS);
  }
  if (sms.getSubjectGroup() == 0) {
    sms.setSubjectGroup(StudyModuleStatus.NOT_STARTED);
  }
  if (sms.getSubjectGroup() != 3 && subjectGroupCount > 0) {
    sms.setSubjectGroup(StudyModuleStatus.IN_PROGRESS);
  }
  if (sms.getRule() == 0) {
    sms.setRule(StudyModuleStatus.NOT_STARTED);
  }
  if (sms.getRule() != 3 && ruleCount > 0) {
    sms.setRule(StudyModuleStatus.IN_PROGRESS);
  }
  if (sms.getSite() == 0) {
    sms.setSite(StudyModuleStatus.NOT_STARTED);
  }
  if (sms.getSite() != 3 && siteCount > 0) {
    sms.setSite(StudyModuleStatus.IN_PROGRESS);
  }
  if (sms.getUsers() == 0) {
    sms.setUsers(StudyModuleStatus.NOT_STARTED);
  }
  if (sms.getUsers() != 3 && userCount > 0) {
    sms.setUsers(StudyModuleStatus.IN_PROGRESS);
  }
  map.addObject(sms);
  map.addAttribute("String_Node_Str",totalCrf);
  map.addAttribute("String_Node_Str",eventDefinitionCount);
  map.addAttribute("String_Node_Str",subjectGroupCount);
  map.addAttribute("String_Node_Str",ruleCount);
  map.addAttribute("String_Node_Str",siteCount);
  map.addAttribute("String_Node_Str",userCount);
  map.addAttribute("String_Node_Str",childStudyUserCount);
  map.addAttribute("String_Node_Str",currentStudy.getId());
  map.addAttribute("String_Node_Str",currentStudy);
  UserAccountBean userBean=(UserAccountBean)request.getSession().getAttribute("String_Node_Str");
  request.setAttribute("String_Node_Str",userBean);
  ArrayList statusMap=Status.toStudyUpdateMembersList();
  request.setAttribute("String_Node_Str",statusMap);
  if (currentStudy.getParentStudyId() > 0) {
    StudyBean parentStudy=(StudyBean)studyDao.findByPK(currentStudy.getParentStudyId());
    request.setAttribute("String_Node_Str",parentStudy);
  }
  ArrayList pageMessages=new ArrayList();
  if (request.getSession().getAttribute("String_Node_Str") != null) {
    pageMessages.addAll((ArrayList)request.getSession().getAttribute("String_Node_Str"));
    request.setAttribute("String_Node_Str",pageMessages);
    request.getSession().removeAttribute("String_Node_Str");
  }
  return map;
}

Fixed version (ground truth):
@RequestMapping(method=RequestMethod.GET) public ModelMap handleMainPage(HttpServletRequest request){
  ModelMap map=new ModelMap();
  StudyInfoPanel panel=new StudyInfoPanel();
  panel.reset();
  request.getSession().setAttribute("String_Node_Str",panel);
  ResourceBundleProvider.updateLocale(request.getLocale());
  StudyBean currentStudy=(StudyBean)request.getSession().getAttribute("String_Node_Str");
  eventDefinitionCRFDao=new EventDefinitionCRFDAO(dataSource);
  studyEventDefinitionDao=new StudyEventDefinitionDAO(dataSource);
  crfDao=new CRFDAO(dataSource);
  studyGroupClassDao=new StudyGroupClassDAO(dataSource);
  studyDao=new StudyDAO(dataSource);
  userDao=new UserAccountDAO(dataSource);
  ruleDao=new RuleDAO(dataSource);
  StudyModuleStatus sms=studyModuleStatusDao.findByStudyId(currentStudy.getId());
  if (sms == null) {
    sms=new StudyModuleStatus();
    sms.setStudyId(currentStudy.getId());
  }
  int crfCount=crfDao.findAllByStudy(currentStudy.getId()).size();
  int crfWithEventDefinition=crfDao.findAllActiveByDefinitions(currentStudy.getId()).size();
  int totalCrf=crfCount + crfWithEventDefinition;
  int eventDefinitionCount=studyEventDefinitionDao.findAllActiveByStudy(currentStudy).size();
  int subjectGroupCount=studyGroupClassDao.findAllActiveByStudy(currentStudy).size();
  int ruleCount=ruleSetService.getCountByStudy(currentStudy);
  int siteCount=studyDao.findOlnySiteIdsByStudy(currentStudy).size();
  int userCount=userDao.findAllUsersByStudy(currentStudy.getId()).size();
  Collection childStudies=studyDao.findAllByParent(currentStudy.getId());
  Map childStudyUserCount=new HashMap();
  for (  Object sb : childStudies) {
    StudyBean childStudy=(StudyBean)sb;
    childStudyUserCount.put(childStudy.getName(),userDao.findAllUsersByStudy(childStudy.getId()).size());
  }
  if (sms.getCrf() == 0) {
    sms.setCrf(StudyModuleStatus.NOT_STARTED);
  }
  if (sms.getCrf() != 3 && totalCrf > 0) {
    sms.setCrf(StudyModuleStatus.IN_PROGRESS);
  }
  if (sms.getEventDefinition() == 0) {
    sms.setEventDefinition(StudyModuleStatus.NOT_STARTED);
  }
  if (sms.getEventDefinition() != 3 && eventDefinitionCount > 0) {
    sms.setEventDefinition(StudyModuleStatus.IN_PROGRESS);
  }
  if (sms.getSubjectGroup() == 0) {
    sms.setSubjectGroup(StudyModuleStatus.NOT_STARTED);
  }
  if (sms.getSubjectGroup() != 3 && subjectGroupCount > 0) {
    sms.setSubjectGroup(StudyModuleStatus.IN_PROGRESS);
  }
  if (sms.getRule() == 0) {
    sms.setRule(StudyModuleStatus.NOT_STARTED);
  }
  if (sms.getRule() != 3 && ruleCount > 0) {
    sms.setRule(StudyModuleStatus.IN_PROGRESS);
  }
  if (sms.getSite() == 0) {
    sms.setSite(StudyModuleStatus.NOT_STARTED);
  }
  if (sms.getSite() != 3 && siteCount > 0) {
    sms.setSite(StudyModuleStatus.IN_PROGRESS);
  }
  if (sms.getUsers() == 0) {
    sms.setUsers(StudyModuleStatus.NOT_STARTED);
  }
  if (sms.getUsers() != 3 && userCount > 0) {
    sms.setUsers(StudyModuleStatus.IN_PROGRESS);
  }
  map.addObject(sms);
  map.addAttribute("String_Node_Str",totalCrf);
  map.addAttribute("String_Node_Str",eventDefinitionCount);
  map.addAttribute("String_Node_Str",subjectGroupCount);
  map.addAttribute("String_Node_Str",ruleCount);
  map.addAttribute("String_Node_Str",siteCount);
  map.addAttribute("String_Node_Str",userCount);
  map.addAttribute("String_Node_Str",childStudyUserCount);
  map.addAttribute("String_Node_Str",currentStudy.getId());
  map.addAttribute("String_Node_Str",currentStudy);
  if (null != coreResources) {
    map.addAttribute("String_Node_Str",coreResources.getField("String_Node_Str"));
  }
  UserAccountBean userBean=(UserAccountBean)request.getSession().getAttribute("String_Node_Str");
  request.setAttribute("String_Node_Str",userBean);
  ArrayList statusMap=Status.toStudyUpdateMembersList();
  request.setAttribute("String_Node_Str",statusMap);
  if (currentStudy.getParentStudyId() > 0) {
    StudyBean parentStudy=(StudyBean)studyDao.findByPK(currentStudy.getParentStudyId());
    request.setAttribute("String_Node_Str",parentStudy);
  }
  ArrayList pageMessages=new ArrayList();
  if (request.getSession().getAttribute("String_Node_Str") != null) {
    pageMessages.addAll((ArrayList)request.getSession().getAttribute("String_Node_Str"));
    request.setAttribute("String_Node_Str",pageMessages);
    request.getSession().removeAttribute("String_Node_Str");
  }
  return map;
}