Program: 5368
Project: 5368
Buggy source:
/** 
 * Start a Program.
 * @param programId  the {@link ProgramId program} to start
 * @param systemArgs system arguments
 * @param userArgs user arguments
 * @param debug enable debug mode
 * @return {@link ProgramRuntimeService.RuntimeInfo}
 * @throws IOException if there is an error starting the program
 * @throws ProgramNotFoundException if program is not found
 * @throws UnauthorizedException if the logged in user is not authorized to start the program. To start a program,a user requires  {@link Action#EXECUTE} on the program
 * @throws Exception if there were other exceptions checking if the current user is authorized to start the program
 */
public ProgramRuntimeService.RuntimeInfo start(final ProgramId programId,final Map<String,String> systemArgs,final Map<String,String> userArgs,boolean debug) throws Exception {
  authorizationEnforcer.enforce(programId,authenticationContext.getPrincipal(),Action.EXECUTE);
  ProgramDescriptor programDescriptor=store.loadProgram(programId);
  BasicArguments systemArguments=new BasicArguments(systemArgs);
  BasicArguments userArguments=new BasicArguments(userArgs);
  ProgramRuntimeService.RuntimeInfo runtimeInfo=runtimeService.run(programDescriptor,new SimpleProgramOptions(programId.getProgram(),systemArguments,userArguments,debug));
  final ProgramController controller=runtimeInfo.getController();
  final String runId=controller.getRunId().getId();
  final String twillRunId=runtimeInfo.getTwillRunId() == null ? null : runtimeInfo.getTwillRunId().getId();
  if (programId.getType() != ProgramType.MAPREDUCE && programId.getType() != ProgramType.SPARK && programId.getType() != ProgramType.WORKFLOW) {
    controller.addListener(new AbstractListener(){
      @Override public void init(      ProgramController.State state,      @Nullable Throwable cause){
        long startTimeInSeconds=RunIds.getTime(controller.getRunId(),TimeUnit.SECONDS);
        if (startTimeInSeconds == -1) {
          startTimeInSeconds=TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());
        }
        store.setStart(programId,runId,startTimeInSeconds,twillRunId,userArgs,systemArgs);
        if (state == ProgramController.State.COMPLETED) {
          completed();
        }
        if (state == ProgramController.State.ERROR) {
          error(controller.getFailureCause());
        }
      }
      @Override public void completed(){
        LOG.debug("String_Node_Str",programId);
        store.setStop(programId,runId,TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()),ProgramController.State.COMPLETED.getRunStatus());
      }
      @Override public void killed(){
        LOG.debug("String_Node_Str",programId);
        store.setStop(programId,runId,TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()),ProgramController.State.KILLED.getRunStatus());
      }
      @Override public void suspended(){
        LOG.debug("String_Node_Str",programId,runId);
        store.setSuspend(programId,runId);
      }
      @Override public void resuming(){
        LOG.debug("String_Node_Str",programId,runId);
        store.setResume(programId,runId);
      }
      @Override public void error(      Throwable cause){
        LOG.info("String_Node_Str",programId,runId,cause);
        store.setStop(programId,runId,TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()),ProgramController.State.ERROR.getRunStatus(),new BasicThrowable(cause));
      }
    }
,Threads.SAME_THREAD_EXECUTOR);
  }
  return runtimeInfo;
}

Fixed version (ground truth):
/** 
 * Start a Program.
 * @param programId  the {@link ProgramId program} to start
 * @param systemArgs system arguments
 * @param userArgs user arguments
 * @param debug enable debug mode
 * @return {@link ProgramRuntimeService.RuntimeInfo}
 * @throws IOException if there is an error starting the program
 * @throws ProgramNotFoundException if program is not found
 * @throws UnauthorizedException if the logged in user is not authorized to start the program. To start a program,a user requires  {@link Action#EXECUTE} on the program
 * @throws Exception if there were other exceptions checking if the current user is authorized to start the program
 */
public ProgramRuntimeService.RuntimeInfo start(final ProgramId programId,final Map<String,String> systemArgs,final Map<String,String> userArgs,boolean debug) throws Exception {
  authorizationEnforcer.enforce(programId,authenticationContext.getPrincipal(),Action.EXECUTE);
  ProgramDescriptor programDescriptor=store.loadProgram(programId);
  BasicArguments systemArguments=new BasicArguments(systemArgs);
  BasicArguments userArguments=new BasicArguments(userArgs);
  ProgramRuntimeService.RuntimeInfo runtimeInfo=runtimeService.run(programDescriptor,new SimpleProgramOptions(programId.getProgram(),systemArguments,userArguments,debug));
  final ProgramController controller=runtimeInfo.getController();
  final String runId=controller.getRunId().getId();
  final String twillRunId=runtimeInfo.getTwillRunId() == null ? null : runtimeInfo.getTwillRunId().getId();
  if (programId.getType() != ProgramType.MAPREDUCE && programId.getType() != ProgramType.SPARK && programId.getType() != ProgramType.WORKFLOW) {
    controller.addListener(new AbstractListener(){
      @Override public void init(      ProgramController.State state,      @Nullable Throwable cause){
        long startTimeInSeconds=RunIds.getTime(controller.getRunId(),TimeUnit.SECONDS);
        if (startTimeInSeconds == -1) {
          startTimeInSeconds=TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());
        }
        final long finalStartTimeInSeconds=startTimeInSeconds;
        Retries.supplyWithRetries(new Supplier<Void>(){
          @Override public Void get(){
            store.setStart(programId,runId,finalStartTimeInSeconds,twillRunId,userArgs,systemArgs);
            return null;
          }
        }
,RetryStrategies.fixDelay(Constants.Retry.RUN_RECORD_UPDATE_RETRY_DELAY_SECS,TimeUnit.SECONDS));
        if (state == ProgramController.State.COMPLETED) {
          completed();
        }
        if (state == ProgramController.State.ERROR) {
          error(controller.getFailureCause());
        }
      }
      @Override public void completed(){
        LOG.debug("String_Node_Str",programId);
        Retries.supplyWithRetries(new Supplier<Void>(){
          @Override public Void get(){
            store.setStop(programId,runId,TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()),ProgramController.State.COMPLETED.getRunStatus());
            return null;
          }
        }
,RetryStrategies.fixDelay(Constants.Retry.RUN_RECORD_UPDATE_RETRY_DELAY_SECS,TimeUnit.SECONDS));
      }
      @Override public void killed(){
        LOG.debug("String_Node_Str",programId);
        Retries.supplyWithRetries(new Supplier<Void>(){
          @Override public Void get(){
            store.setStop(programId,runId,TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()),ProgramController.State.KILLED.getRunStatus());
            return null;
          }
        }
,RetryStrategies.fixDelay(Constants.Retry.RUN_RECORD_UPDATE_RETRY_DELAY_SECS,TimeUnit.SECONDS));
      }
      @Override public void suspended(){
        LOG.debug("String_Node_Str",programId,runId);
        Retries.supplyWithRetries(new Supplier<Void>(){
          @Override public Void get(){
            store.setSuspend(programId,runId);
            return null;
          }
        }
,RetryStrategies.fixDelay(Constants.Retry.RUN_RECORD_UPDATE_RETRY_DELAY_SECS,TimeUnit.SECONDS));
      }
      @Override public void resuming(){
        LOG.debug("String_Node_Str",programId,runId);
        Retries.supplyWithRetries(new Supplier<Void>(){
          @Override public Void get(){
            store.setResume(programId,runId);
            return null;
          }
        }
,RetryStrategies.fixDelay(Constants.Retry.RUN_RECORD_UPDATE_RETRY_DELAY_SECS,TimeUnit.SECONDS));
      }
      @Override public void error(      final Throwable cause){
        LOG.info("String_Node_Str",programId,runId,cause);
        Retries.supplyWithRetries(new Supplier<Void>(){
          @Override public Void get(){
            store.setStop(programId,runId,TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()),ProgramController.State.ERROR.getRunStatus(),new BasicThrowable(cause));
            return null;
          }
        }
,RetryStrategies.fixDelay(Constants.Retry.RUN_RECORD_UPDATE_RETRY_DELAY_SECS,TimeUnit.SECONDS));
      }
    }
,Threads.SAME_THREAD_EXECUTOR);
  }
  return runtimeInfo;
}