Program: 55264
Project: 55264
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.
 * @return the duration of the job execution in milliseconds
 * @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 long 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 int interval=this.jobSubmitClient.getRecommendedPollingInterval();
    sleep=interval * 1000;
  }
 catch (  IOException ioe) {
    Runtime.getRuntime().removeShutdownHook(this.jobCleanUp);
    throw ioe;
  }
  try {
    Thread.sleep(sleep / 2);
  }
 catch (  InterruptedException e) {
    Runtime.getRuntime().removeShutdownHook(this.jobCleanUp);
    logErrorAndRethrow(StringUtils.stringifyException(e));
  }
  long startTimestamp=-1;
  while (true) {
    if (Thread.interrupted()) {
      logErrorAndRethrow("String_Node_Str");
    }
    JobProgressResult jobProgressResult=null;
    try {
      jobProgressResult=getJobProgress();
    }
 catch (    IOException ioe) {
      Runtime.getRuntime().removeShutdownHook(this.jobCleanUp);
      throw ioe;
    }
    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.lastProcessedEventSequenceNumber >= event.getSequenceNumber()) {
        continue;
      }
      System.out.println(event.toString());
      this.lastProcessedEventSequenceNumber=event.getSequenceNumber();
      if (event instanceof JobEvent) {
        final JobEvent jobEvent=(JobEvent)event;
        final JobStatus jobStatus=jobEvent.getCurrentJobStatus();
        if (jobStatus == JobStatus.SCHEDULED) {
          startTimestamp=jobEvent.getTimestamp();
        }
        if (jobStatus == JobStatus.FINISHED) {
          Runtime.getRuntime().removeShutdownHook(this.jobCleanUp);
          final long jobDuration=jobEvent.getTimestamp() - startTimestamp;
          System.out.println("String_Node_Str" + jobDuration);
          return jobDuration;
        }
 else         if (jobStatus == JobStatus.CANCELED || jobStatus == JobStatus.FAILED) {
          Runtime.getRuntime().removeShutdownHook(this.jobCleanUp);
          LOG.info(jobEvent.getOptionalMessage());
          if (jobStatus == JobStatus.CANCELED) {
            throw new JobExecutionException(jobEvent.getOptionalMessage(),true);
          }
 else {
            throw new JobExecutionException(jobEvent.getOptionalMessage(),false);
          }
        }
      }
    }
    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.
 * @return the duration of the job execution in milliseconds
 * @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 long submitJobAndWait() throws IOException, JobExecutionException {
  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 int interval=this.jobSubmitClient.getRecommendedPollingInterval();
    sleep=interval * 1000;
  }
 catch (  IOException ioe) {
    Runtime.getRuntime().removeShutdownHook(this.jobCleanUp);
    throw ioe;
  }
  try {
    Thread.sleep(sleep / 2);
  }
 catch (  InterruptedException e) {
    Runtime.getRuntime().removeShutdownHook(this.jobCleanUp);
    logErrorAndRethrow(StringUtils.stringifyException(e));
  }
  long startTimestamp=-1;
  while (true) {
    if (Thread.interrupted()) {
      logErrorAndRethrow("String_Node_Str");
    }
    JobProgressResult jobProgressResult=null;
    try {
      jobProgressResult=getJobProgress();
    }
 catch (    IOException ioe) {
      Runtime.getRuntime().removeShutdownHook(this.jobCleanUp);
      throw ioe;
    }
    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.lastProcessedEventSequenceNumber >= event.getSequenceNumber()) {
        continue;
      }
      System.out.println(event.toString());
      this.lastProcessedEventSequenceNumber=event.getSequenceNumber();
      if (event instanceof JobEvent) {
        final JobEvent jobEvent=(JobEvent)event;
        final JobStatus jobStatus=jobEvent.getCurrentJobStatus();
        if (jobStatus == JobStatus.SCHEDULED) {
          startTimestamp=jobEvent.getTimestamp();
        }
        if (jobStatus == JobStatus.FINISHED) {
          close();
          Runtime.getRuntime().removeShutdownHook(this.jobCleanUp);
          final long jobDuration=jobEvent.getTimestamp() - startTimestamp;
          System.out.println("String_Node_Str" + jobDuration);
          return jobDuration;
        }
 else         if (jobStatus == JobStatus.CANCELED || jobStatus == JobStatus.FAILED) {
          close();
          Runtime.getRuntime().removeShutdownHook(this.jobCleanUp);
          LOG.info(jobEvent.getOptionalMessage());
          if (jobStatus == JobStatus.CANCELED) {
            throw new JobExecutionException(jobEvent.getOptionalMessage(),true);
          }
 else {
            throw new JobExecutionException(jobEvent.getOptionalMessage(),false);
          }
        }
      }
    }
    try {
      Thread.sleep(sleep);
    }
 catch (    InterruptedException e) {
      logErrorAndRethrow(StringUtils.stringifyException(e));
    }
  }
}