Program: 5199
Project: 5199
Buggy source:
@Override protected void startUp() throws Exception {
  Reflections.visit(spark,spark.getClass(),new PropertyFieldSetter(runtimeContext.getSparkSpecification().getProperties()),new DataSetFieldSetter(runtimeContext.getDatasetCache()),new MetricsFieldSetter(runtimeContext));
  initialize();
  File tempDir=DirUtils.createTempDir(new File(cConf.get(Constants.CFG_LOCAL_DATA_DIR),cConf.get(Constants.AppFabric.TEMP_DIR)).getAbsoluteFile());
  tempDir.mkdirs();
  this.cleanupTask=createCleanupTask(tempDir,System.getProperties());
  try {
    SparkRuntimeContextConfig contextConfig=new SparkRuntimeContextConfig(runtimeContext.getConfiguration());
    final File jobJar=generateJobJar(tempDir);
    final List<LocalizeResource> localizeResources=new ArrayList<>();
    String metricsConfPath;
    String logbackJarName=null;
    File sparkJar=null;
    List<String> extraJars=new ArrayList<>();
    if (contextConfig.isLocal()) {
      copyUserResources(context.getLocalizeResources(),tempDir);
      File metricsConf=SparkMetricsSink.writeConfig(File.createTempFile("String_Node_Str","String_Node_Str",tempDir));
      metricsConfPath=metricsConf.getAbsolutePath();
    }
 else {
      distributedUserResources(context.getLocalizeResources(),localizeResources);
      File programJar=Locations.linkOrCopy(runtimeContext.getProgram().getJarLocation(),new File(tempDir,SparkRuntimeContextProvider.PROGRAM_JAR_NAME));
      File expandedProgramJar=Locations.linkOrCopy(runtimeContext.getProgram().getJarLocation(),new File(tempDir,SparkRuntimeContextProvider.PROGRAM_JAR_EXPANDED_NAME));
      localizeResources.add(new LocalizeResource(programJar));
      localizeResources.add(new LocalizeResource(expandedProgramJar,true));
      localizeResources.add(new LocalizeResource(createLauncherJar(tempDir)));
      sparkJar=buildDependencyJar(tempDir);
      localizeResources.add(new LocalizeResource(sparkJar,true));
      localizeResources.add(new LocalizeResource(saveCConf(cConf,tempDir)));
      if (pluginArchive != null) {
        localizeResources.add(new LocalizeResource(pluginArchive,true));
      }
      File logbackJar=ProgramRunners.createLogbackJar(tempDir);
      if (logbackJar != null) {
        localizeResources.add(new LocalizeResource(logbackJar));
        logbackJarName=logbackJar.getName();
      }
      File metricsConf=SparkMetricsSink.writeConfig(File.createTempFile("String_Node_Str","String_Node_Str",new File(System.getProperty("String_Node_Str"))));
      metricsConfPath=metricsConf.getName();
      localizeResources.add(new LocalizeResource(metricsConf));
      Configuration hConf=contextConfig.set(runtimeContext,pluginArchive).getConfiguration();
      localizeResources.add(new LocalizeResource(saveHConf(hConf,tempDir)));
      for (      URI jarURI : CConfigurationUtil.getExtraJars(cConf)) {
        extraJars.add(LocalizationUtils.getLocalizedName(jarURI));
        localizeResources.add(new LocalizeResource(jarURI,false));
      }
    }
    final Map<String,String> configs=createSubmitConfigs(sparkJar,tempDir,metricsConfPath,logbackJarName,context.getLocalizeResources(),extraJars,contextConfig.isLocal());
    submitSpark=new Callable<ListenableFuture<RunId>>(){
      @Override public ListenableFuture<RunId> call() throws Exception {
        if (!isRunning()) {
          return immediateCancelledFuture();
        }
        return sparkSubmitter.submit(runtimeContext,configs,localizeResources,jobJar,runtimeContext.getRunId());
      }
    }
;
  }
 catch (  Throwable t) {
    cleanupTask.run();
    throw t;
  }
}

Fixed version (ground truth):
@Override protected void startUp() throws Exception {
  Reflections.visit(spark,spark.getClass(),new PropertyFieldSetter(runtimeContext.getSparkSpecification().getProperties()),new DataSetFieldSetter(runtimeContext.getDatasetCache()),new MetricsFieldSetter(runtimeContext));
  File tempDir=DirUtils.createTempDir(new File(cConf.get(Constants.CFG_LOCAL_DATA_DIR),cConf.get(Constants.AppFabric.TEMP_DIR)).getAbsoluteFile());
  tempDir.mkdirs();
  this.cleanupTask=createCleanupTask(tempDir,System.getProperties());
  try {
    initialize();
    SparkRuntimeContextConfig contextConfig=new SparkRuntimeContextConfig(runtimeContext.getConfiguration());
    final File jobJar=generateJobJar(tempDir);
    final List<LocalizeResource> localizeResources=new ArrayList<>();
    String metricsConfPath;
    String logbackJarName=null;
    File sparkJar=null;
    List<String> extraJars=new ArrayList<>();
    if (contextConfig.isLocal()) {
      copyUserResources(context.getLocalizeResources(),tempDir);
      File metricsConf=SparkMetricsSink.writeConfig(File.createTempFile("String_Node_Str","String_Node_Str",tempDir));
      metricsConfPath=metricsConf.getAbsolutePath();
    }
 else {
      distributedUserResources(context.getLocalizeResources(),localizeResources);
      File programJar=Locations.linkOrCopy(runtimeContext.getProgram().getJarLocation(),new File(tempDir,SparkRuntimeContextProvider.PROGRAM_JAR_NAME));
      File expandedProgramJar=Locations.linkOrCopy(runtimeContext.getProgram().getJarLocation(),new File(tempDir,SparkRuntimeContextProvider.PROGRAM_JAR_EXPANDED_NAME));
      localizeResources.add(new LocalizeResource(programJar));
      localizeResources.add(new LocalizeResource(expandedProgramJar,true));
      localizeResources.add(new LocalizeResource(createLauncherJar(tempDir)));
      sparkJar=buildDependencyJar(tempDir);
      localizeResources.add(new LocalizeResource(sparkJar,true));
      localizeResources.add(new LocalizeResource(saveCConf(cConf,tempDir)));
      if (pluginArchive != null) {
        localizeResources.add(new LocalizeResource(pluginArchive,true));
      }
      File logbackJar=ProgramRunners.createLogbackJar(tempDir);
      if (logbackJar != null) {
        localizeResources.add(new LocalizeResource(logbackJar));
        logbackJarName=logbackJar.getName();
      }
      File metricsConf=SparkMetricsSink.writeConfig(File.createTempFile("String_Node_Str","String_Node_Str",new File(System.getProperty("String_Node_Str"))));
      metricsConfPath=metricsConf.getName();
      localizeResources.add(new LocalizeResource(metricsConf));
      Configuration hConf=contextConfig.set(runtimeContext,pluginArchive).getConfiguration();
      localizeResources.add(new LocalizeResource(saveHConf(hConf,tempDir)));
      for (      URI jarURI : CConfigurationUtil.getExtraJars(cConf)) {
        extraJars.add(LocalizationUtils.getLocalizedName(jarURI));
        localizeResources.add(new LocalizeResource(jarURI,false));
      }
    }
    final Map<String,String> configs=createSubmitConfigs(sparkJar,tempDir,metricsConfPath,logbackJarName,context.getLocalizeResources(),extraJars,contextConfig.isLocal());
    submitSpark=new Callable<ListenableFuture<RunId>>(){
      @Override public ListenableFuture<RunId> call() throws Exception {
        if (!isRunning()) {
          return immediateCancelledFuture();
        }
        return sparkSubmitter.submit(runtimeContext,configs,localizeResources,jobJar,runtimeContext.getRunId());
      }
    }
;
  }
 catch (  LinkageError e) {
    throw new Exception(e.getMessage(),e);
  }
catch (  Throwable t) {
    cleanupTask.run();
    throw t;
  }
}