Program: 88166
Project: 88166
Buggy source:
/** 
 * Submits the job assigned to this job client to the job manager and queries the job manager about the progress of the job until it is either finished or aborted.
 * @throws IOException thrown if an error occurred while transmitting the request
 * @throws JobExecutionException thrown if the job has been aborted either by the user or as a result of an error
 */
public void submitJobAndWait() throws IOException, JobExecutionException {
synchronized (this.jobSubmitClient) {
    final JobSubmissionResult submissionResult=this.jobSubmitClient.submitJob(this.jobGraph);
    if (submissionResult.getReturnCode() == AbstractJobResult.ReturnCode.ERROR) {
      LOG.error("String_Node_Str" + submissionResult.getDescription());
      throw new JobExecutionException(submissionResult.getDescription(),false);
    }
 else {
      Runtime.getRuntime().addShutdownHook(this.jobCleanUp);
    }
  }
  long sleep=0;
  try {
    final IntegerRecord interval=this.jobSubmitClient.getRecommendedPollingInterval();
    sleep=interval.getValue() * 1000;
  }
 catch (  IOException ioe) {
    logErrorAndRethrow(StringUtils.stringifyException(ioe));
  }
  try {
    Thread.sleep(sleep / 2);
  }
 catch (  InterruptedException e) {
    logErrorAndRethrow(StringUtils.stringifyException(e));
  }
  while (true) {
    if (Thread.interrupted()) {
      logErrorAndRethrow("String_Node_Str");
    }
    final JobProgressResult jobProgressResult=getJobProgress();
    if (jobProgressResult == null) {
      logErrorAndRethrow("String_Node_Str");
    }
    if (jobProgressResult.getReturnCode() == AbstractJobResult.ReturnCode.ERROR) {
      logErrorAndRethrow("String_Node_Str" + jobProgressResult.getDescription());
    }
    final Iterator<AbstractEvent> it=jobProgressResult.getEvents();
    while (it.hasNext()) {
      final AbstractEvent event=it.next();
      if (this.processedEvents.contains(event)) {
        continue;
      }
      System.out.println(event.toString());
      this.processedEvents.add(event);
      if (event instanceof JobEvent) {
        final JobEvent jobEvent=(JobEvent)event;
        final JobStatus jobStatus=jobEvent.getCurrentJobStatus();
        if (jobStatus == JobStatus.FINISHED) {
          Runtime.getRuntime().removeShutdownHook(this.jobCleanUp);
          return;
        }
 else         if (jobStatus == JobStatus.CANCELED || jobStatus == JobStatus.FAILED) {
          Runtime.getRuntime().removeShutdownHook(this.jobCleanUp);
          LOG.info(jobEvent.getOptionalMessage());
          throw new JobExecutionException(jobEvent.getOptionalMessage(),(jobStatus == JobStatus.CANCELED) ? true : false);
        }
      }
    }
    cleanUpOldEvents(sleep);
    try {
      Thread.sleep(sleep);
    }
 catch (    InterruptedException e) {
      logErrorAndRethrow(StringUtils.stringifyException(e));
    }
  }
}

Fixed version (ground truth):
/** 
 * Submits the job assigned to this job client to the job manager and queries the job manager about the progress of the job until it is either finished or aborted.
 * @throws IOException thrown if an error occurred while transmitting the request
 * @throws JobExecutionException thrown if the job has been aborted either by the user or as a result of an error
 */
public void submitJobAndWait() throws IOException, JobExecutionException {
synchronized (this.jobSubmitClient) {
    final JobSubmissionResult submissionResult=this.jobSubmitClient.submitJob(this.jobGraph);
    if (submissionResult.getReturnCode() == AbstractJobResult.ReturnCode.ERROR) {
      LOG.error("String_Node_Str" + submissionResult.getDescription());
      throw new JobExecutionException(submissionResult.getDescription(),false);
    }
    Runtime.getRuntime().addShutdownHook(this.jobCleanUp);
  }
  long sleep=0;
  try {
    final IntegerRecord interval=this.jobSubmitClient.getRecommendedPollingInterval();
    sleep=interval.getValue() * 1000;
  }
 catch (  IOException ioe) {
    logErrorAndRethrow(StringUtils.stringifyException(ioe));
  }
  try {
    Thread.sleep(sleep / 2);
  }
 catch (  InterruptedException e) {
    logErrorAndRethrow(StringUtils.stringifyException(e));
  }
  while (true) {
    if (Thread.interrupted()) {
      logErrorAndRethrow("String_Node_Str");
    }
    final JobProgressResult jobProgressResult=getJobProgress();
    if (jobProgressResult == null) {
      logErrorAndRethrow("String_Node_Str");
    }
    if (jobProgressResult.getReturnCode() == AbstractJobResult.ReturnCode.ERROR) {
      logErrorAndRethrow("String_Node_Str" + jobProgressResult.getDescription());
    }
    final Iterator<AbstractEvent> it=jobProgressResult.getEvents();
    while (it.hasNext()) {
      final AbstractEvent event=it.next();
      if (this.processedEvents.contains(event)) {
        continue;
      }
      System.out.println(event.toString());
      this.processedEvents.add(event);
      if (event instanceof JobEvent) {
        final JobEvent jobEvent=(JobEvent)event;
        final JobStatus jobStatus=jobEvent.getCurrentJobStatus();
        if (jobStatus == JobStatus.FINISHED) {
          Runtime.getRuntime().removeShutdownHook(this.jobCleanUp);
          return;
        }
 else         if (jobStatus == JobStatus.CANCELED || jobStatus == JobStatus.FAILED) {
          Runtime.getRuntime().removeShutdownHook(this.jobCleanUp);
          LOG.info(jobEvent.getOptionalMessage());
          throw new JobExecutionException(jobEvent.getOptionalMessage(),(jobStatus == JobStatus.CANCELED) ? true : false);
        }
      }
    }
    cleanUpOldEvents(sleep);
    try {
      Thread.sleep(sleep);
    }
 catch (    InterruptedException e) {
      logErrorAndRethrow(StringUtils.stringifyException(e));
    }
  }
}