Program: 89655
Project: 89655
Buggy source:
/** 
 * Check if jobs should be generated for any ready harvest definitions for the specified time.
 * @param timeToGenerateJobsFor Jobs will be generated which should berun at this time. Note: In a production system the provided time will normally be current time, but during testing we need to simulated other points-in-time
 */
static void generateJobs(Date timeToGenerateJobsFor){
  final Iterable<Long> readyHarvestDefinitions=haDefinitionDAO.getReadyHarvestDefinitions(timeToGenerateJobsFor);
  for (  final Long id : readyHarvestDefinitions) {
    if (harvestDefinitionsBeingScheduled.contains(id)) {
      log.debug("String_Node_Str" + id + "String_Node_Str");
      continue;
    }
    final HarvestDefinition harvestDefinition=haDefinitionDAO.read(id);
    harvestDefinitionsBeingScheduled.add(id);
    if (!harvestDefinition.runNow(timeToGenerateJobsFor)) {
      log.trace("String_Node_Str" + harvestDefinition.getName() + "String_Node_Str");
      log.trace("String_Node_Str" + harvestDefinition.getNumEvents());
      continue;
    }
    new Thread("String_Node_Str" + id){
      public void run(){
        try {
          int jobsMade=harvestDefinition.createJobs();
          log.info("String_Node_Str" + jobsMade + "String_Node_Str"+ harvestDefinition.getName()+ "String_Node_Str");
          haDefinitionDAO.update(harvestDefinition);
        }
 catch (        Throwable e) {
          try {
            HarvestDefinition hd=haDefinitionDAO.read(harvestDefinition.getOid());
            hd.setActive(false);
            haDefinitionDAO.update(hd);
            String errMsg="String_Node_Str" + "String_Node_Str" + harvestDefinition.getName() + "String_Node_Str"+ "String_Node_Str";
            log.warn(errMsg,e);
            NotificationsFactory.getInstance().errorEvent(errMsg,e);
          }
 catch (          Exception e1) {
            String errMsg="String_Node_Str" + "String_Node_Str" + harvestDefinition.getName() + "String_Node_Str"+ "String_Node_Str";
            log.warn(errMsg,e);
            log.warn("String_Node_Str",e1);
            NotificationsFactory.getInstance().errorEvent(errMsg,e);
          }
        }
 finally {
          harvestDefinitionsBeingScheduled.remove(id);
          log.debug("String_Node_Str" + harvestDefinition.getName() + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ harvestDefinitionsBeingScheduled);
        }
      }
    }
.start();
  }
}

Fixed version (ground truth):
/** 
 * Check if jobs should be generated for any ready harvest definitions for the specified time.
 * @param timeToGenerateJobsFor Jobs will be generated which should berun at this time. Note: In a production system the provided time will normally be current time, but during testing we need to simulated other points-in-time
 */
static void generateJobs(Date timeToGenerateJobsFor){
  final Iterable<Long> readyHarvestDefinitions=haDefinitionDAO.getReadyHarvestDefinitions(timeToGenerateJobsFor);
  for (  final Long id : readyHarvestDefinitions) {
    if (harvestDefinitionsBeingScheduled.contains(id)) {
      String harvestName=haDefinitionDAO.getHarvestName(id);
      String errMsg="String_Node_Str" + id + "String_Node_Str"+ harvestName+ "String_Node_Str"+ "String_Node_Str";
      log.warn(errMsg);
      NotificationsFactory.getInstance().errorEvent(errMsg);
      continue;
    }
    final HarvestDefinition harvestDefinition=haDefinitionDAO.read(id);
    harvestDefinitionsBeingScheduled.add(id);
    if (!harvestDefinition.runNow(timeToGenerateJobsFor)) {
      log.trace("String_Node_Str" + harvestDefinition.getName() + "String_Node_Str");
      log.trace("String_Node_Str" + harvestDefinition.getNumEvents());
      continue;
    }
    new Thread("String_Node_Str" + id){
      public void run(){
        try {
          int jobsMade=harvestDefinition.createJobs();
          log.info("String_Node_Str" + jobsMade + "String_Node_Str"+ harvestDefinition.getName()+ "String_Node_Str");
          haDefinitionDAO.update(harvestDefinition);
        }
 catch (        Throwable e) {
          try {
            HarvestDefinition hd=haDefinitionDAO.read(harvestDefinition.getOid());
            hd.setActive(false);
            haDefinitionDAO.update(hd);
            String errMsg="String_Node_Str" + "String_Node_Str" + harvestDefinition.getName() + "String_Node_Str"+ "String_Node_Str";
            log.warn(errMsg,e);
            NotificationsFactory.getInstance().errorEvent(errMsg,e);
          }
 catch (          Exception e1) {
            String errMsg="String_Node_Str" + "String_Node_Str" + harvestDefinition.getName() + "String_Node_Str"+ "String_Node_Str";
            log.warn(errMsg,e);
            log.warn("String_Node_Str",e1);
            NotificationsFactory.getInstance().errorEvent(errMsg,e);
          }
        }
 finally {
          harvestDefinitionsBeingScheduled.remove(id);
          log.debug("String_Node_Str" + harvestDefinition.getName() + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ harvestDefinitionsBeingScheduled);
        }
      }
    }
.start();
  }
}