Program: 84583
Project: 84583
Buggy source:
/** 
 * The onSubmit function receives the form/command object that was modified by the input form and saves it to the db
 * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,java.lang.Object,org.springframework.validation.BindException)
 */
protected ModelAndView onSubmit(HttpServletRequest request,HttpServletResponse response,Object obj,BindException errors) throws Exception {
  HttpSession httpSession=request.getSession();
  ConceptService cs=Context.getConceptService();
  if (Context.isAuthenticated()) {
    Concept concept=(Concept)obj;
    MessageSourceAccessor msa=getMessageSourceAccessor();
    String action=request.getParameter("String_Node_Str");
    if (action.equals(msa.getMessage("String_Node_Str"))) {
      try {
        cs.deleteConcept(concept);
        httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR,"String_Node_Str");
        return new ModelAndView(new RedirectView("String_Node_Str"));
      }
 catch (      APIException e) {
        log.error(e);
        httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR,"String_Node_Str");
        return new ModelAndView(new RedirectView(getSuccessView() + "String_Node_Str" + concept.getConceptId().toString()));
      }
    }
 else {
      String isSet=ServletRequestUtils.getStringParameter(request,"String_Node_Str","String_Node_Str");
      if (isSet.equals("String_Node_Str"))       concept.setSet(false);
 else       concept.setSet(true);
      boolean isNew=false;
      try {
        if (concept.getConceptId() == null) {
          isNew=true;
          concept.setConceptId(cs.getNextAvailableId());
          if (concept.getDatatype() != null && concept.getDatatype().getName().equals("String_Node_Str")) {
            concept=getConceptNumeric(concept,request);
          }
          cs.saveConcept(concept);
        }
 else {
          if (concept.getDatatype() != null && concept.getDatatype().getName().equals("String_Node_Str")) {
            concept=getConceptNumeric(concept,request);
          }
          cs.saveConcept(concept);
        }
        httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR,"String_Node_Str");
      }
 catch (      APIException e) {
        log.error("String_Node_Str",e);
        httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR,"String_Node_Str");
        if (isNew) {
          errors.reject("String_Node_Str","String_Node_Str");
          return new ModelAndView(new RedirectView(getSuccessView()));
        }
      }
      return new ModelAndView(new RedirectView(getSuccessView() + "String_Node_Str" + concept.getConceptId()));
    }
  }
  return new ModelAndView(new RedirectView(getFormView()));
}

Fixed version (ground truth):
/** 
 * The onSubmit function receives the form/command object that was modified by the input form and saves it to the db
 * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,java.lang.Object,org.springframework.validation.BindException)
 */
protected ModelAndView onSubmit(HttpServletRequest request,HttpServletResponse response,Object obj,BindException errors) throws Exception {
  HttpSession httpSession=request.getSession();
  ConceptService cs=Context.getConceptService();
  if (Context.isAuthenticated()) {
    Concept concept=(Concept)obj;
    MessageSourceAccessor msa=getMessageSourceAccessor();
    String action=request.getParameter("String_Node_Str");
    if (action.equals(msa.getMessage("String_Node_Str"))) {
      try {
        cs.purgeConcept(concept);
        httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR,"String_Node_Str");
        return new ModelAndView(new RedirectView("String_Node_Str"));
      }
 catch (      APIException e) {
        log.error(e);
        httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR,"String_Node_Str");
        return new ModelAndView(new RedirectView(getSuccessView() + "String_Node_Str" + concept.getConceptId().toString()));
      }
    }
 else {
      String isSet=ServletRequestUtils.getStringParameter(request,"String_Node_Str","String_Node_Str");
      if (isSet.equals("String_Node_Str"))       concept.setSet(false);
 else       concept.setSet(true);
      boolean isNew=false;
      try {
        if (concept.getConceptId() == null) {
          isNew=true;
          concept.setConceptId(cs.getNextAvailableId());
          if (concept.getDatatype() != null && concept.getDatatype().getName().equals("String_Node_Str")) {
            concept=getConceptNumeric(concept,request);
          }
          cs.saveConcept(concept);
        }
 else {
          if (concept.getDatatype() != null && concept.getDatatype().getName().equals("String_Node_Str")) {
            concept=getConceptNumeric(concept,request);
          }
          cs.saveConcept(concept);
        }
        httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR,"String_Node_Str");
      }
 catch (      APIException e) {
        log.error("String_Node_Str",e);
        httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR,"String_Node_Str");
        if (isNew) {
          errors.reject("String_Node_Str","String_Node_Str");
          return new ModelAndView(new RedirectView(getSuccessView()));
        }
      }
      return new ModelAndView(new RedirectView(getSuccessView() + "String_Node_Str" + concept.getConceptId()));
    }
  }
  return new ModelAndView(new RedirectView(getFormView()));
}