Program: 89730
Project: 89730
Buggy source:
/** 
 * Submit those jobs that are ready for submission if the relevant  message queue is empty.
 */
synchronized void submitNewJobs(){
  final JobDAO dao=JobDAO.getInstance();
  Iterator<Long> jobsToSubmit=dao.getAllJobIds(JobStatus.NEW);
  if (!jobsToSubmit.hasNext()) {
    log.trace("String_Node_Str");
  }
 else {
    log.trace("String_Node_Str");
  }
  int numberOfSubmittedJobs=0;
  while (jobsToSubmit.hasNext()) {
    final long jobID=jobsToSubmit.next();
    Job jobToSubmit=null;
    try {
      jobToSubmit=dao.read(jobID);
      if (isQueueEmpty(JobChannelUtil.getChannel(jobToSubmit.getPriority()))) {
        jobToSubmit.setStatus(JobStatus.SUBMITTED);
        jobToSubmit.setSubmittedDate(new Date());
        dao.update(jobToSubmit);
        List<MetadataEntry> metadata=new ArrayList<MetadataEntry>();
        MetadataEntry aliasMetadataEntry=MetadataEntry.makeAliasMetadataEntry(jobToSubmit.getJobAliasInfo(),jobToSubmit.getOrigHarvestDefinitionID(),jobToSubmit.getHarvestNum(),jobToSubmit.getJobID());
        if (aliasMetadataEntry != null) {
          metadata.add(aliasMetadataEntry);
        }
        if (HeritrixLauncher.isDeduplicationEnabledInTemplate(jobToSubmit.getOrderXMLdoc())) {
          MetadataEntry duplicateReductionMetadataEntry=MetadataEntry.makeDuplicateReductionMetadataEntry(dao.getJobIDsForDuplicateReduction(jobID),jobToSubmit.getOrigHarvestDefinitionID(),jobToSubmit.getHarvestNum(),jobToSubmit.getJobID());
          if (duplicateReductionMetadataEntry != null) {
            metadata.add(duplicateReductionMetadataEntry);
          }
        }
        doOneCrawl(jobToSubmit,metadata);
        numberOfSubmittedJobs++;
        log.trace("String_Node_Str" + jobToSubmit + "String_Node_Str");
      }
    }
 catch (    Throwable e) {
      String message="String_Node_Str" + jobID;
      log.warn(message,e);
      if (jobToSubmit != null) {
        jobToSubmit.setStatus(JobStatus.FAILED);
        jobToSubmit.appendHarvestErrors(message);
        jobToSubmit.appendHarvestErrorDetails(ExceptionUtils.getStackTrace(e));
        dao.update(jobToSubmit);
      }
    }
  }
  if (numberOfSubmittedJobs > 0) {
    log.info("String_Node_Str" + numberOfSubmittedJobs + "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Submit those jobs that are ready for submission if the relevant message queue is empty.
 */
synchronized void submitNewJobs(){
  final JobDAO dao=JobDAO.getInstance();
  Iterator<Long> jobsToSubmit=dao.getAllJobIds(JobStatus.NEW);
  if (!jobsToSubmit.hasNext()) {
    log.trace("String_Node_Str");
  }
 else {
    log.trace("String_Node_Str");
  }
  int numberOfSubmittedJobs=0;
  while (jobsToSubmit.hasNext()) {
    final long jobID=jobsToSubmit.next();
    Job jobToSubmit=null;
    try {
      jobToSubmit=dao.read(jobID);
      if (isQueueEmpty(JobChannelUtil.getChannel(jobToSubmit.getPriority()))) {
        jobToSubmit.setStatus(JobStatus.SUBMITTED);
        jobToSubmit.setSubmittedDate(new Date());
        dao.update(jobToSubmit);
        List<MetadataEntry> metadata=new ArrayList<MetadataEntry>();
        MetadataEntry aliasMetadataEntry=MetadataEntry.makeAliasMetadataEntry(jobToSubmit.getJobAliasInfo(),jobToSubmit.getOrigHarvestDefinitionID(),jobToSubmit.getHarvestNum(),jobToSubmit.getJobID());
        if (aliasMetadataEntry != null) {
          metadata.add(aliasMetadataEntry);
        }
        if (HeritrixLauncher.isDeduplicationEnabledInTemplate(jobToSubmit.getOrderXMLdoc())) {
          MetadataEntry duplicateReductionMetadataEntry=MetadataEntry.makeDuplicateReductionMetadataEntry(dao.getJobIDsForDuplicateReduction(jobID),jobToSubmit.getOrigHarvestDefinitionID(),jobToSubmit.getHarvestNum(),jobToSubmit.getJobID());
          if (duplicateReductionMetadataEntry != null) {
            metadata.add(duplicateReductionMetadataEntry);
          }
        }
        doOneCrawl(jobToSubmit,metadata);
        numberOfSubmittedJobs++;
        log.trace("String_Node_Str" + jobToSubmit + "String_Node_Str");
      }
    }
 catch (    Throwable e) {
      String message="String_Node_Str" + jobID;
      log.warn(message,e);
      if (jobToSubmit != null) {
        jobToSubmit.setStatus(JobStatus.FAILED);
        jobToSubmit.appendHarvestErrors(message);
        jobToSubmit.appendHarvestErrorDetails(ExceptionUtils.getStackTrace(e));
        dao.update(jobToSubmit);
      }
    }
  }
  if (numberOfSubmittedJobs > 0) {
    log.info("String_Node_Str" + numberOfSubmittedJobs + "String_Node_Str");
  }
}