Program: 4863
Project: 4863
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));
  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,contextConfig.isLocal(),cConf);
    final List<LocalizeResource> localizeResources=new ArrayList<>();
    String metricsConfPath;
    String classpath="String_Node_Str";
    Properties sparkDefaultConf=SparkPackageUtils.getSparkDefaultConf();
    for (    String key : sparkDefaultConf.stringPropertyNames()) {
      SparkRuntimeEnv.setProperty(key,sparkDefaultConf.getProperty(key));
    }
    if (contextConfig.isLocal()) {
      copyUserResources(context.getLocalizeResources(),tempDir);
      File metricsConf=SparkMetricsSink.writeConfig(new File(tempDir,CDAP_METRICS_PROPERTIES));
      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));
      if (pluginArchive != null) {
        localizeResources.add(new LocalizeResource(pluginArchive,true));
      }
      localizeResources.add(new LocalizeResource(createLauncherJar(tempDir)));
      File metricsConf=SparkMetricsSink.writeConfig(new File(CDAP_METRICS_PROPERTIES));
      metricsConfPath=metricsConf.getName();
      localizeResources.add(new LocalizeResource(metricsConf));
      localizeResources.add(new LocalizeResource(saveCConf(cConf,tempDir)));
      Configuration hConf=contextConfig.set(runtimeContext,pluginArchive).getConfiguration();
      localizeResources.add(new LocalizeResource(saveHConf(hConf,tempDir)));
      Joiner joiner=Joiner.on(File.pathSeparator).skipNulls();
      File sparkJar=new File(tempDir,CDAP_SPARK_JAR);
      classpath=joiner.join(Iterables.transform(buildDependencyJar(sparkJar),new Function<String,String>(){
        @Override public String apply(        String name){
          return Paths.get("String_Node_Str",CDAP_SPARK_JAR,name).toString();
        }
      }
));
      localizeResources.add(new LocalizeResource(sparkJar,true));
      File logbackJar=ProgramRunners.createLogbackJar(new File(tempDir,"String_Node_Str"));
      if (logbackJar != null) {
        localizeResources.add(new LocalizeResource(logbackJar));
        classpath=joiner.join(Paths.get("String_Node_Str",logbackJar.getName()),classpath);
      }
      List<String> extraJars=new ArrayList<>();
      for (      URI jarURI : CConfigurationUtil.getExtraJars(cConf)) {
        extraJars.add(Paths.get("String_Node_Str",LocalizationUtils.getLocalizedName(jarURI)).toString());
        localizeResources.add(new LocalizeResource(jarURI,false));
      }
      classpath=joiner.join(classpath,joiner.join(extraJars));
    }
    final Map<String,String> configs=createSubmitConfigs(tempDir,metricsConfPath,classpath,context.getLocalizeResources(),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;
  }
}

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));
  CConfiguration cConfCopy=CConfiguration.copy(cConf);
  File tempDir=DirUtils.createTempDir(new File(cConfCopy.get(Constants.CFG_LOCAL_DATA_DIR),cConfCopy.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,contextConfig.isLocal(),cConfCopy);
    final List<LocalizeResource> localizeResources=new ArrayList<>();
    String metricsConfPath;
    String classpath="String_Node_Str";
    Properties sparkDefaultConf=SparkPackageUtils.getSparkDefaultConf();
    for (    String key : sparkDefaultConf.stringPropertyNames()) {
      SparkRuntimeEnv.setProperty(key,sparkDefaultConf.getProperty(key));
    }
    if (contextConfig.isLocal()) {
      copyUserResources(context.getLocalizeResources(),tempDir);
      File metricsConf=SparkMetricsSink.writeConfig(new File(tempDir,CDAP_METRICS_PROPERTIES));
      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));
      if (pluginArchive != null) {
        localizeResources.add(new LocalizeResource(pluginArchive,true));
      }
      localizeResources.add(new LocalizeResource(createLauncherJar(tempDir)));
      File metricsConf=SparkMetricsSink.writeConfig(new File(CDAP_METRICS_PROPERTIES));
      metricsConfPath=metricsConf.getName();
      localizeResources.add(new LocalizeResource(metricsConf));
      prepareHBaseDDLExecutorResources(tempDir,cConfCopy,localizeResources);
      localizeResources.add(new LocalizeResource(saveCConf(cConfCopy,tempDir)));
      Configuration hConf=contextConfig.set(runtimeContext,pluginArchive).getConfiguration();
      localizeResources.add(new LocalizeResource(saveHConf(hConf,tempDir)));
      Joiner joiner=Joiner.on(File.pathSeparator).skipNulls();
      File sparkJar=new File(tempDir,CDAP_SPARK_JAR);
      classpath=joiner.join(Iterables.transform(buildDependencyJar(sparkJar),new Function<String,String>(){
        @Override public String apply(        String name){
          return Paths.get("String_Node_Str",CDAP_SPARK_JAR,name).toString();
        }
      }
));
      localizeResources.add(new LocalizeResource(sparkJar,true));
      File logbackJar=ProgramRunners.createLogbackJar(new File(tempDir,"String_Node_Str"));
      if (logbackJar != null) {
        localizeResources.add(new LocalizeResource(logbackJar));
        classpath=joiner.join(Paths.get("String_Node_Str",logbackJar.getName()),classpath);
      }
      List<String> extraJars=new ArrayList<>();
      for (      URI jarURI : CConfigurationUtil.getExtraJars(cConfCopy)) {
        extraJars.add(Paths.get("String_Node_Str",LocalizationUtils.getLocalizedName(jarURI)).toString());
        localizeResources.add(new LocalizeResource(jarURI,false));
      }
      classpath=joiner.join(classpath,joiner.join(extraJars));
    }
    final Map<String,String> configs=createSubmitConfigs(tempDir,metricsConfPath,classpath,context.getLocalizeResources(),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;
  }
}