Program: 90185
Project: 90185
Buggy source:
/** 
 * Updates the harvest definition with posted values.
 * @param context The context that the web request processing happens in
 * @param i18n Translation information for this site section.
 * @param unknownDomains List to add unknown but legal domains to.
 * @param illegalDomains List to add illegal domains to.
 * @return The updated harvest definition.  This object holds an editionthat is legal to use for further updates (adding or deleting domains)
 */
private static PartialHarvest updateHarvestDefinition(PageContext context,I18n i18n,List<String> unknownDomains,List<String> illegalDomains){
  ServletRequest request=context.getRequest();
  HTMLUtils.forwardOnEmptyParameter(context,Constants.HARVEST_PARAM,Constants.SCHEDULE_PARAM);
  String name=request.getParameter(Constants.HARVEST_PARAM);
  HTMLUtils.forwardOnMissingParameter(context,Constants.COMMENTS_PARAM,Constants.DOMAINLIST_PARAM);
  String scheduleName=request.getParameter(Constants.SCHEDULE_PARAM);
  Schedule sched=ScheduleDAO.getInstance().read(scheduleName);
  if (sched == null) {
    HTMLUtils.forwardWithErrorMessage(context,i18n,"String_Node_Str",sched);
    throw new ForwardedToErrorPage("String_Node_Str" + sched + "String_Node_Str");
  }
  String comments=request.getParameter(Constants.COMMENTS_PARAM);
  List<DomainConfiguration> dc=getDomainConfigurations(request.getParameterMap());
  addDomainsToConfigurations(dc,request.getParameter(Constants.DOMAINLIST_PARAM),unknownDomains,illegalDomains);
  HarvestDefinitionDAO hddao=HarvestDefinitionDAO.getInstance();
  if ((request.getParameter(Constants.CREATENEW_PARAM) != null)) {
    if (hddao.getHarvestDefinition(name) != null) {
      HTMLUtils.forwardWithErrorMessage(context,i18n,"String_Node_Str",name);
      throw new ForwardedToErrorPage("String_Node_Str" + "String_Node_Str" + name + "String_Node_Str");
    }
    PartialHarvest hdd=new PartialHarvest(dc,sched,name,comments);
    hdd.setActive(false);
    hddao.create(hdd);
    return hdd;
  }
 else {
    long edition=HTMLUtils.parseOptionalLong(context,Constants.EDITION_PARAM,Constants.NO_EDITION);
    PartialHarvest hdd=(PartialHarvest)hddao.getHarvestDefinition(name);
    if (hdd.getEdition() != edition) {
      HTMLUtils.forwardWithRawErrorMessage(context,i18n,"String_Node_Str","String_Node_Str" + Constants.HARVEST_PARAM + "String_Node_Str"+ HTMLUtils.encodeAndEscapeHTML(name)+ "String_Node_Str","String_Node_Str");
      throw new ForwardedToErrorPage("String_Node_Str" + name + "String_Node_Str");
    }
    hdd.setDomainConfigurations(dc);
    hdd.setSchedule(sched);
    hdd.setComments(comments);
    hddao.update(hdd);
    return hdd;
  }
}

Fixed version (ground truth):
/** 
 * Updates the harvest definition with posted values.
 * @param context The context that the web request processing happens in
 * @param i18n Translation information for this site section.
 * @param unknownDomains List to add unknown but legal domains to.
 * @param illegalDomains List to add illegal domains to.
 * @return The updated harvest definition.  This object holds an editionthat is legal to use for further updates (adding or deleting domains)
 */
private static PartialHarvest updateHarvestDefinition(PageContext context,I18n i18n,List<String> unknownDomains,List<String> illegalDomains){
  ServletRequest request=context.getRequest();
  HTMLUtils.forwardOnEmptyParameter(context,Constants.HARVEST_PARAM,Constants.SCHEDULE_PARAM);
  String name=request.getParameter(Constants.HARVEST_PARAM);
  HTMLUtils.forwardOnMissingParameter(context,Constants.COMMENTS_PARAM,Constants.DOMAINLIST_PARAM);
  String scheduleName=request.getParameter(Constants.SCHEDULE_PARAM);
  Schedule sched=ScheduleDAO.getInstance().read(scheduleName);
  if (sched == null) {
    HTMLUtils.forwardWithErrorMessage(context,i18n,"String_Node_Str",scheduleName);
    throw new ForwardedToErrorPage("String_Node_Str" + scheduleName + "String_Node_Str");
  }
  String comments=request.getParameter(Constants.COMMENTS_PARAM);
  List<DomainConfiguration> dc=getDomainConfigurations(request.getParameterMap());
  addDomainsToConfigurations(dc,request.getParameter(Constants.DOMAINLIST_PARAM),unknownDomains,illegalDomains);
  HarvestDefinitionDAO hddao=HarvestDefinitionDAO.getInstance();
  if ((request.getParameter(Constants.CREATENEW_PARAM) != null)) {
    if (hddao.getHarvestDefinition(name) != null) {
      HTMLUtils.forwardWithErrorMessage(context,i18n,"String_Node_Str",name);
      throw new ForwardedToErrorPage("String_Node_Str" + "String_Node_Str" + name + "String_Node_Str");
    }
    PartialHarvest hdd=new PartialHarvest(dc,sched,name,comments);
    hdd.setActive(false);
    hddao.create(hdd);
    return hdd;
  }
 else {
    long edition=HTMLUtils.parseOptionalLong(context,Constants.EDITION_PARAM,Constants.NO_EDITION);
    PartialHarvest hdd=(PartialHarvest)hddao.getHarvestDefinition(name);
    if (hdd.getEdition() != edition) {
      HTMLUtils.forwardWithRawErrorMessage(context,i18n,"String_Node_Str","String_Node_Str" + Constants.HARVEST_PARAM + "String_Node_Str"+ HTMLUtils.encodeAndEscapeHTML(name)+ "String_Node_Str","String_Node_Str");
      throw new ForwardedToErrorPage("String_Node_Str" + name + "String_Node_Str");
    }
    hdd.setDomainConfigurations(dc);
    hdd.setSchedule(sched);
    hdd.setComments(comments);
    hddao.update(hdd);
    return hdd;
  }
}