Program: 7093
Project: 7093
Buggy source:
/** 
 * Creates a service listener to reactor on state changes on   {@link MapReduceRuntimeService}.
 */
private Service.Listener createRuntimeServiceListener(final Program program,final RunId runId,final AdapterDefinition adapterSpec,final String twillRunId,final PluginInstantiator pluginInstantiator){
  return new ServiceListenerAdapter(){
    @Override public void starting(){
      long startTimeInSeconds=RunIds.getTime(runId,TimeUnit.SECONDS);
      if (startTimeInSeconds == -1) {
        startTimeInSeconds=TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());
      }
      String adapterName=adapterSpec == null ? null : adapterSpec.getName();
      if (workflowName == null) {
        store.setStart(program.getId(),runId.getId(),startTimeInSeconds,adapterName,twillRunId);
      }
 else {
        store.setWorkflowProgramStart(program.getId(),runId.getId(),workflowName,workflowRunId,workflowNodeId,startTimeInSeconds,adapterName,twillRunId);
      }
    }
    @Override public void terminated(    Service.State from){
      Closeables.closeQuietly(pluginInstantiator);
      if (from == Service.State.STOPPING) {
        store.setStop(program.getId(),runId.getId(),TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()),ProgramController.State.KILLED.getRunStatus());
      }
 else {
        store.setStop(program.getId(),runId.getId(),TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()),ProgramController.State.COMPLETED.getRunStatus());
      }
    }
    @Override public void failed(    Service.State from,    Throwable failure){
      Closeables.closeQuietly(pluginInstantiator);
      store.setStop(program.getId(),runId.getId(),TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()),ProgramController.State.ERROR.getRunStatus());
    }
  }
;
}

Fixed version (ground truth):
/** 
 * Creates a service listener to reactor on state changes on   {@link MapReduceRuntimeService}.
 */
private Service.Listener createRuntimeServiceListener(final Program program,final RunId runId,final AdapterDefinition adapterSpec,final PluginInstantiator pluginInstantiator,Arguments arguments){
  final String twillRunId=arguments.getOption(ProgramOptionConstants.TWILL_RUN_ID);
  final String workflowName=arguments.getOption(ProgramOptionConstants.WORKFLOW_NAME);
  final String workflowNodeId=arguments.getOption(ProgramOptionConstants.WORKFLOW_NODE_ID);
  final String workflowRunId=arguments.getOption(ProgramOptionConstants.WORKFLOW_RUN_ID);
  return new ServiceListenerAdapter(){
    @Override public void starting(){
      long startTimeInSeconds=RunIds.getTime(runId,TimeUnit.SECONDS);
      if (startTimeInSeconds == -1) {
        startTimeInSeconds=TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());
      }
      String adapterName=adapterSpec == null ? null : adapterSpec.getName();
      if (workflowName == null) {
        store.setStart(program.getId(),runId.getId(),startTimeInSeconds,adapterName,twillRunId);
      }
 else {
        store.setWorkflowProgramStart(program.getId(),runId.getId(),workflowName,workflowRunId,workflowNodeId,startTimeInSeconds,adapterName,twillRunId);
      }
    }
    @Override public void terminated(    Service.State from){
      Closeables.closeQuietly(pluginInstantiator);
      if (from == Service.State.STOPPING) {
        store.setStop(program.getId(),runId.getId(),TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()),ProgramController.State.KILLED.getRunStatus());
      }
 else {
        store.setStop(program.getId(),runId.getId(),TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()),ProgramController.State.COMPLETED.getRunStatus());
      }
    }
    @Override public void failed(    Service.State from,    Throwable failure){
      Closeables.closeQuietly(pluginInstantiator);
      store.setStop(program.getId(),runId.getId(),TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()),ProgramController.State.ERROR.getRunStatus());
    }
  }
;
}