nus-yam/ex-repair huggingface dataset:
Program: 7467
Project: 7467
Buggy source:
/** 
 * Check if any program that satisfy the given   {@link Predicate} is running.
 * @param predicate Get call on each running {@link Id.Program}.
 * @param types Types of program to checkreturns True if a program is running as defined by the predicate.
 */
private boolean checkAnyRunning(Predicate<Id.Program> predicate,ProgramType... types){
  for (  ProgramType type : types) {
    for (    Map.Entry<RunId,ProgramRuntimeService.RuntimeInfo> entry : runtimeService.list(type).entrySet()) {
      ProgramController.State programState=entry.getValue().getController().getState();
      if (programState != ProgramController.State.STOPPED && programState != ProgramController.State.ERROR) {
        Id.Program programId=entry.getValue().getProgramId();
        if (predicate.apply(programId)) {
          LOG.trace("String_Node_Str",programId.getApplicationId(),type,programId.getId(),entry.getValue().getController().getRunId());
          return true;
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Check if any program that satisfy the given   {@link Predicate} is running.
 * @param predicate Get call on each running {@link Id.Program}.
 * @param types Types of program to checkreturns True if a program is running as defined by the predicate.
 */
private boolean checkAnyRunning(Predicate<Id.Program> predicate,ProgramType... types){
  for (  ProgramType type : types) {
    for (    Map.Entry<RunId,ProgramRuntimeService.RuntimeInfo> entry : runtimeService.list(type).entrySet()) {
      ProgramController.State programState=entry.getValue().getController().getState();
      if (programState == ProgramController.State.STOPPED || programState == ProgramController.State.ERROR) {
        continue;
      }
      Id.Program programId=entry.getValue().getProgramId();
      if (predicate.apply(programId)) {
        LOG.trace("String_Node_Str",programId.getApplicationId(),type,programId.getId(),entry.getValue().getController().getRunId());
        return true;
      }
    }
  }
  return false;
}
Program: 7468
Project: 7468
Buggy source:
public static void main(String[] args){
  Configuration config=HBaseConfiguration.create();
  TransactionManagerDebuggerMain instance=new TransactionManagerDebuggerMain(config);
  boolean success=instance.execute(args,config);
  if (!success) {
    System.exit(1);
  }
}

Fixed version (ground truth):
public static void main(String[] args){
  CConfiguration cConf=CConfiguration.create();
  Configuration hConf=new Configuration();
  cConf.copyTxProperties(hConf);
  TransactionManagerDebuggerMain instance=new TransactionManagerDebuggerMain(hConf);
  boolean success=instance.execute(args);
  if (!success) {
    System.exit(1);
  }
}
Program: 7469
Project: 7469
Buggy source:
private boolean execute(String[] args,Configuration conf){
  if (args.length <= 0) {
    printUsage(true);
    return false;
  }
  mode=DebuggerMode.fromString(args[0]);
  if (mode == DebuggerMode.INVALID) {
    printUsage(true);
    return false;
  }
  List<String> subArgs=Arrays.asList(args).subList(1,args.length);
  return parseArgsAndExecMode(subArgs.toArray(new String[0]),conf);
}

Fixed version (ground truth):
private boolean execute(String[] args){
  if (args.length <= 0) {
    printUsage(true);
    return false;
  }
  mode=DebuggerMode.fromString(args[0]);
  if (mode == DebuggerMode.INVALID) {
    printUsage(true);
    return false;
  }
  List<String> subArgs=Arrays.asList(args).subList(1,args.length);
  return parseArgsAndExecMode(subArgs.toArray(new String[0]),hConf);
}
Program: 7470
Project: 7470
Buggy source:
private TransactionManagerDebuggerMain(Configuration configuration){
  codecProvider=new SnapshotCodecProvider(configuration);
  buildOptions();
}

Fixed version (ground truth):
private TransactionManagerDebuggerMain(Configuration configuration){
  codecProvider=new SnapshotCodecProvider(configuration);
  buildOptions();
  this.hConf=configuration;
}
Program: 7471
Project: 7471
Buggy source:
/** 
 * Increments (atomically) the specified row and columns by the specified amounts. NOTE: depending on the implementation this may work faster than calling   {@link #incrementAndGet(byte[],byte[],long)}multiple times (esp. in transaction that changes a lot of rows)
 * @param row row which values to increment
 * @param columns columns to increment
 * @param amounts amounts to increment columns by (same order as columns)
 * @return values of counters after the increments are performed, never null
 */
Map<byte[],Long> incrementAndGet(byte[] row,byte[][] columns,long[] amounts) throws Exception ;

Fixed version (ground truth):
/** 
 * Increments (atomically) the specified row and columns by the specified amounts. NOTE: depending on the implementation this may work faster than calling  {@link #incrementAndGet(byte[],byte[],long)} multiple times (esp. in transaction that changes a lot of rows).
 * @param row row which values to increment
 * @param columns columns to increment
 * @param amounts amounts to increment columns by (same order as columns)
 * @return values of counters after the increments are performed, never null
 */
Map<byte[],Long> incrementAndGet(byte[] row,byte[][] columns,long[] amounts) throws Exception ;
Program: 7472
Project: 7472
Buggy source:
@Override public List<QueryResult> previewResults(QueryHandle handle) throws ExploreException, HandleNotFoundException, SQLException {
  if (inactiveHandleCache.getIfPresent(handle) != null) {
    throw new HandleNotFoundException("String_Node_Str",true);
  }
  OperationInfo operationInfo=getOperationInfo(handle);
  File previewFile=operationInfo.getPreviewFile();
  if (previewFile != null) {
    try {
      Reader reader=new FileReader(previewFile);
      try {
        return GSON.fromJson(reader,new TypeToken<List<QueryResult>>(){
        }
.getType());
      }
  finally {
        Closeables.closeQuietly(reader);
      }
    }
 catch (    FileNotFoundException e) {
      LOG.error("String_Node_Str",previewFile,e);
      throw new ExploreException(e);
    }
  }
  FileWriter fileWriter=null;
  try {
    previewFile=new File(previewsDir,handle.getHandle());
    fileWriter=new FileWriter(previewFile);
    List<QueryResult> results=nextResults(handle,PREVIEW_COUNT);
    GSON.toJson(results,fileWriter);
    operationInfo.setPreviewFile(previewFile);
    return results;
  }
 catch (  IOException e) {
    LOG.error("String_Node_Str",e);
    throw new ExploreException(e);
  }
 finally {
    if (fileWriter != null) {
      Closeables.closeQuietly(fileWriter);
    }
  }
}

Fixed version (ground truth):
@Override public List<QueryResult> previewResults(QueryHandle handle) throws ExploreException, HandleNotFoundException, SQLException {
  if (inactiveHandleCache.getIfPresent(handle) != null) {
    throw new HandleNotFoundException("String_Node_Str",true);
  }
  OperationInfo operationInfo=getOperationInfo(handle);
  operationInfo.getPreviewLock().lock();
  try {
    File previewFile=operationInfo.getPreviewFile();
    if (previewFile != null) {
      try {
        Reader reader=new FileReader(previewFile);
        try {
          return GSON.fromJson(reader,new TypeToken<List<QueryResult>>(){
          }
.getType());
        }
  finally {
          Closeables.closeQuietly(reader);
        }
      }
 catch (      FileNotFoundException e) {
        LOG.error("String_Node_Str",previewFile,e);
        throw new ExploreException(e);
      }
    }
    FileWriter fileWriter=null;
    try {
      previewFile=new File(previewsDir,handle.getHandle());
      fileWriter=new FileWriter(previewFile);
      List<QueryResult> results=nextResults(handle,PREVIEW_COUNT);
      GSON.toJson(results,fileWriter);
      operationInfo.setPreviewFile(previewFile);
      return results;
    }
 catch (    IOException e) {
      LOG.error("String_Node_Str",e);
      throw new ExploreException(e);
    }
 finally {
      if (fileWriter != null) {
        Closeables.closeQuietly(fileWriter);
      }
    }
  }
  finally {
    operationInfo.getPreviewLock().unlock();
  }
}
Program: 7473
Project: 7473
Buggy source:
@Override public List<QueryResult> nextResults(QueryHandle handle,int size) throws ExploreException, HandleNotFoundException, SQLException {
  InactiveOperationInfo inactiveOperationInfo=inactiveHandleCache.getIfPresent(handle);
  if (inactiveOperationInfo != null) {
    LOG.trace("String_Node_Str",handle);
    return ImmutableList.of();
  }
  try {
    LOG.trace("String_Node_Str",handle);
    List<QueryResult> results=fetchNextResults(getOperationHandle(handle),size);
    QueryStatus status=getStatus(handle);
    if (results.isEmpty() && status.getStatus() == QueryStatus.OpStatus.FINISHED) {
      timeoutAggresively(handle,getResultSchema(handle),status);
    }
    return results;
  }
 catch (  HiveSQLException e) {
    throw getSqlException(e);
  }
}

Fixed version (ground truth):
@Override public List<QueryResult> nextResults(QueryHandle handle,int size) throws ExploreException, HandleNotFoundException, SQLException {
  InactiveOperationInfo inactiveOperationInfo=inactiveHandleCache.getIfPresent(handle);
  if (inactiveOperationInfo != null) {
    LOG.trace("String_Node_Str",handle);
    return ImmutableList.of();
  }
  try {
    getOperationInfo(handle).getNextLock().lock();
    try {
      LOG.trace("String_Node_Str",handle);
      List<QueryResult> results=fetchNextResults(getOperationHandle(handle),size);
      QueryStatus status=getStatus(handle);
      if (results.isEmpty() && status.getStatus() == QueryStatus.OpStatus.FINISHED) {
        timeoutAggresively(handle,getResultSchema(handle),status);
      }
      return results;
    }
  finally {
      getOperationInfo(handle).getNextLock().unlock();
    }
  }
 catch (  HiveSQLException e) {
    throw getSqlException(e);
  }
}
Program: 7475
Project: 7475
Buggy source:
@Override public void run(){
  boolean success=false;
  try {
    LoggingContextAccessor.setLoggingContext(context.getLoggingContext());
    LOG.info("String_Node_Str",context.toString());
    ClassLoader oldClassLoader=Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(conf.getClassLoader());
    try {
      SparkProgramWrapper.setSparkProgramRunning(true);
      SparkSubmit.main(sparkSubmitArgs);
    }
 catch (    Exception e) {
      LOG.error("String_Node_Str",context.toString(),e);
    }
 finally {
      success=SparkProgramWrapper.isSparkProgramSuccessful();
      SparkProgramWrapper.setSparkProgramRunning(false);
      Thread.currentThread().setContextClassLoader(oldClassLoader);
    }
  }
 catch (  Exception e) {
    LOG.warn("String_Node_Str",e);
    throw Throwables.propagate(e);
  }
 finally {
    stopController(success,context,job,tx);
    try {
      dependencyJar.delete();
    }
 catch (    IOException e) {
      LOG.warn("String_Node_Str",dependencyJar.toURI());
    }
    try {
      jobJarCopy.delete();
    }
 catch (    IOException e) {
      LOG.warn("String_Node_Str",jobJarCopy.toURI());
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  boolean success=false;
  try {
    LoggingContextAccessor.setLoggingContext(context.getLoggingContext());
    LOG.info("String_Node_Str",context.toString(),Arrays.toString(sparkSubmitArgs));
    ClassLoader oldClassLoader=Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(conf.getClassLoader());
    try {
      SparkProgramWrapper.setSparkProgramRunning(true);
      SparkSubmit.main(sparkSubmitArgs);
    }
 catch (    Exception e) {
      LOG.error("String_Node_Str",context.toString(),e);
    }
 finally {
      success=SparkProgramWrapper.isSparkProgramSuccessful();
      SparkProgramWrapper.setSparkProgramRunning(false);
      Thread.currentThread().setContextClassLoader(oldClassLoader);
    }
  }
 catch (  Exception e) {
    LOG.warn("String_Node_Str",e);
    throw Throwables.propagate(e);
  }
 finally {
    stopController(success,context,job,tx);
    try {
      dependencyJar.delete();
    }
 catch (    IOException e) {
      LOG.warn("String_Node_Str",dependencyJar.toURI());
    }
    try {
      jobJarCopy.delete();
    }
 catch (    IOException e) {
      LOG.warn("String_Node_Str",jobJarCopy.toURI());
    }
  }
}
Program: 7476
Project: 7476
Buggy source:
/** 
 * Prepares arguments which   {@link SparkProgramWrapper} is submitted to {@link SparkSubmit} to run.
 * @param sparkSpec     {@link SparkSpecification} of this job
 * @param conf          {@link Configuration} of the job whose {@link MRConfig#FRAMEWORK_NAME} specifies the mode inwhich spark runs
 * @param jobJarCopy    {@link Location} copy of user program
 * @param dependencyJar {@link Location} jar containing the dependencies of this job
 * @return String[] of arguments with which {@link SparkProgramWrapper} will be submitted
 */
private String[] prepareSparkSubmitArgs(SparkSpecification sparkSpec,Configuration conf,Location jobJarCopy,Location dependencyJar){
  return new String[]{"String_Node_Str",SparkProgramWrapper.class.getCanonicalName(),"String_Node_Str",conf.get(MRConfig.FRAMEWORK_NAME),jobJarCopy.toURI().getPath(),"String_Node_Str",dependencyJar.toURI().getPath(),sparkSpec.getMainClassName()};
}

Fixed version (ground truth):
/** 
 * Prepares arguments which   {@link SparkProgramWrapper} is submitted to {@link SparkSubmit} to run.
 * @param sparkSpec     {@link SparkSpecification} of this job
 * @param conf          {@link Configuration} of the job whose {@link MRConfig#FRAMEWORK_NAME} specifies the mode inwhich spark runs
 * @param jobJarCopy    {@link Location} copy of user program
 * @param dependencyJar {@link Location} jar containing the dependencies of this job
 * @return String[] of arguments with which {@link SparkProgramWrapper} will be submitted
 */
private String[] prepareSparkSubmitArgs(SparkSpecification sparkSpec,Configuration conf,Location jobJarCopy,Location dependencyJar){
  return new String[]{"String_Node_Str",SparkProgramWrapper.class.getCanonicalName(),"String_Node_Str",dependencyJar.toURI().getPath(),"String_Node_Str",conf.get(MRConfig.FRAMEWORK_NAME),jobJarCopy.toURI().getPath(),sparkSpec.getMainClassName()};
}
Program: 7477
Project: 7477
Buggy source:
@Override public void configure(){
  bindConstant().annotatedWith(Names.named("String_Node_Str")).to(webAppPath);
}

Fixed version (ground truth):
@Override protected void configure(){
  bind(PassportClient.class).toProvider(new Provider<PassportClient>(){
    @Override public PassportClient get(){
      return client;
    }
  }
);
  if (webAppPath != null) {
    bindConstant().annotatedWith(Names.named("String_Node_Str")).to(webAppPath);
  }
}
Program: 7479
Project: 7479
Buggy source:
/** 
 * User Spark job which will be executed
 * @param args    the command line arguments
 * @param context {@link SparkContext} for this job
 */
public void run(String[] args,SparkContext context);

Fixed version (ground truth):
/** 
 * User Spark job which will be executed
 * @param context {@link SparkContext} for this job
 */
public void run(SparkContext context);
Program: 7480
Project: 7480
Buggy source:
/** 
 * User Spark job which will be executed
 * @param args    the command line arguments
 * @param context {@link SparkContext} for this job
 */
public void run(String[] args,SparkContext context);

Fixed version (ground truth):
/** 
 * User Spark job which will be executed
 * @param context {@link SparkContext} for this job
 */
public void run(SparkContext context);
Program: 7481
Project: 7481
Buggy source:
/** 
 * Extracts arguments which belongs to user's program and then invokes the run method on the user's program object with the arguments and the appropriate implementation   {@link SparkContext}
 * @param userProgramObject the user program's object
 * @throws RuntimeException if failed to invokeUserProgram main function on the user's program object
 */
private void runUserProgram(Object userProgramObject){
  String[] userprogramArgs=extractUserArgs();
  try {
    Method userProgramMain=userProgramClass.getMethod("String_Node_Str",String[].class,SparkContext.class);
    userProgramMain.invoke(userProgramObject,userprogramArgs,sparkContext);
  }
 catch (  NoSuchMethodException nsme) {
    LOG.warn("String_Node_Str",userProgramObject.getClass().getName(),nsme);
    throw Throwables.propagate(nsme);
  }
catch (  IllegalAccessException iae) {
    LOG.warn("String_Node_Str",userProgramObject.getClass().getName(),iae);
    throw Throwables.propagate(iae);
  }
catch (  InvocationTargetException ite) {
    LOG.warn("String_Node_Str",ite);
    throw Throwables.propagate(ite);
  }
}

Fixed version (ground truth):
/** 
 * Extracts arguments which belongs to user's program and then invokes the run method on the user's program object with the arguments and the appropriate implementation   {@link SparkContext}
 * @param userProgramObject the user program's object
 * @throws RuntimeException if failed to invokeUserProgram main function on the user's program object
 */
private void runUserProgram(Object userProgramObject){
  try {
    Method userProgramMain=userProgramClass.getMethod("String_Node_Str",SparkContext.class);
    userProgramMain.invoke(userProgramObject,sparkContext);
  }
 catch (  NoSuchMethodException nsme) {
    LOG.warn("String_Node_Str",userProgramObject.getClass().getName(),nsme);
    throw Throwables.propagate(nsme);
  }
catch (  IllegalAccessException iae) {
    LOG.warn("String_Node_Str",userProgramObject.getClass().getName(),iae);
    throw Throwables.propagate(iae);
  }
catch (  InvocationTargetException ite) {
    LOG.warn("String_Node_Str",ite);
    throw Throwables.propagate(ite);
  }
}
Program: 7483
Project: 7483
Buggy source:
@Override public void run(){
  boolean success=false;
  try {
    LoggingContextAccessor.setLoggingContext(context.getLoggingContext());
    LOG.info("String_Node_Str",context.toString());
    ClassLoader oldClassLoader=Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(conf.getClassLoader());
    try {
      SparkProgramWrapper.setSparkProgramRunning(true);
      SparkSubmit.main(sparkSubmitArgs);
    }
 catch (    Exception e) {
      LOG.error("String_Node_Str",e);
    }
 finally {
      success=SparkProgramWrapper.isSparkProgramSuccessful();
      SparkProgramWrapper.setSparkProgramRunning(false);
      Thread.currentThread().setContextClassLoader(oldClassLoader);
    }
  }
 catch (  Exception e) {
    throw Throwables.propagate(e);
  }
 finally {
    stopController(success,context,job,tx);
    try {
      dependencyJar.delete();
    }
 catch (    IOException e) {
      LOG.warn("String_Node_Str",dependencyJar.toURI());
    }
    try {
      jobJarCopy.delete();
    }
 catch (    IOException e) {
      LOG.warn("String_Node_Str",jobJarCopy.toURI());
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  boolean success=false;
  try {
    LoggingContextAccessor.setLoggingContext(context.getLoggingContext());
    LOG.info("String_Node_Str",context.toString());
    ClassLoader oldClassLoader=Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(conf.getClassLoader());
    try {
      SparkProgramWrapper.setSparkProgramRunning(true);
      SparkSubmit.main(sparkSubmitArgs);
    }
 catch (    Exception e) {
      LOG.error("String_Node_Str",context.toString(),e);
    }
 finally {
      success=SparkProgramWrapper.isSparkProgramSuccessful();
      SparkProgramWrapper.setSparkProgramRunning(false);
      Thread.currentThread().setContextClassLoader(oldClassLoader);
    }
  }
 catch (  Exception e) {
    LOG.warn("String_Node_Str",e);
    throw Throwables.propagate(e);
  }
 finally {
    stopController(success,context,job,tx);
    try {
      dependencyJar.delete();
    }
 catch (    IOException e) {
      LOG.warn("String_Node_Str",dependencyJar.toURI());
    }
    try {
      jobJarCopy.delete();
    }
 catch (    IOException e) {
      LOG.warn("String_Node_Str",jobJarCopy.toURI());
    }
  }
}
Program: 7484
Project: 7484
Buggy source:
@Override public boolean programExists(final Id.Program id,final ProgramType type){
  return txnl.executeUnchecked(new TransactionExecutor.Function<AppMds,Boolean>(){
    @Override public Boolean apply(    AppMds mds) throws Exception {
      ApplicationSpecification appSpec=getApplicationSpec(mds,id.getApplication());
      if (appSpec == null) {
        return false;
      }
      ProgramSpecification programSpecification=null;
      try {
        if (type == ProgramType.FLOW) {
          programSpecification=getFlowSpecOrFail(id,appSpec);
        }
 else         if (type == ProgramType.PROCEDURE) {
          programSpecification=getProcedureSpecOrFail(id,appSpec);
        }
 else         if (type == ProgramType.SERVICE) {
          programSpecification=getServiceSpecOrFail(id,appSpec);
        }
 else         if (type == ProgramType.WORKFLOW) {
          programSpecification=appSpec.getWorkflows().get(id.getId());
        }
 else         if (type == ProgramType.MAPREDUCE) {
          programSpecification=appSpec.getMapReduce().get(id.getId());
        }
 else         if (type == ProgramType.WEBAPP) {
        }
 else {
          throw new IllegalArgumentException("String_Node_Str");
        }
      }
 catch (      NoSuchElementException e) {
        programSpecification=null;
      }
catch (      Exception e) {
        Throwables.propagate(e);
      }
      return (programSpecification != null);
    }
  }
);
}

Fixed version (ground truth):
@Override public boolean programExists(final Id.Program id,final ProgramType type){
  return txnl.executeUnchecked(new TransactionExecutor.Function<AppMds,Boolean>(){
    @Override public Boolean apply(    AppMds mds) throws Exception {
      ApplicationSpecification appSpec=getApplicationSpec(mds,id.getApplication());
      if (appSpec == null) {
        return false;
      }
      ProgramSpecification programSpecification=null;
      try {
        if (type == ProgramType.FLOW) {
          programSpecification=getFlowSpecOrFail(id,appSpec);
        }
 else         if (type == ProgramType.PROCEDURE) {
          programSpecification=getProcedureSpecOrFail(id,appSpec);
        }
 else         if (type == ProgramType.SERVICE) {
          programSpecification=getServiceSpecOrFail(id,appSpec);
        }
 else         if (type == ProgramType.WORKFLOW) {
          programSpecification=appSpec.getWorkflows().get(id.getId());
        }
 else         if (type == ProgramType.MAPREDUCE) {
          programSpecification=appSpec.getMapReduce().get(id.getId());
        }
 else         if (type == ProgramType.SPARK) {
          programSpecification=appSpec.getSpark().get(id.getId());
        }
 else         if (type == ProgramType.WEBAPP) {
        }
 else {
          throw new IllegalArgumentException("String_Node_Str");
        }
      }
 catch (      NoSuchElementException e) {
        programSpecification=null;
      }
catch (      Exception e) {
        Throwables.propagate(e);
      }
      return (programSpecification != null);
    }
  }
);
}
Program: 7485
Project: 7485
Buggy source:
@Override public Boolean apply(AppMds mds) throws Exception {
  ApplicationSpecification appSpec=getApplicationSpec(mds,id.getApplication());
  if (appSpec == null) {
    return false;
  }
  ProgramSpecification programSpecification=null;
  try {
    if (type == ProgramType.FLOW) {
      programSpecification=getFlowSpecOrFail(id,appSpec);
    }
 else     if (type == ProgramType.PROCEDURE) {
      programSpecification=getProcedureSpecOrFail(id,appSpec);
    }
 else     if (type == ProgramType.SERVICE) {
      programSpecification=getServiceSpecOrFail(id,appSpec);
    }
 else     if (type == ProgramType.WORKFLOW) {
      programSpecification=appSpec.getWorkflows().get(id.getId());
    }
 else     if (type == ProgramType.MAPREDUCE) {
      programSpecification=appSpec.getMapReduce().get(id.getId());
    }
 else     if (type == ProgramType.WEBAPP) {
    }
 else {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
 catch (  NoSuchElementException e) {
    programSpecification=null;
  }
catch (  Exception e) {
    Throwables.propagate(e);
  }
  return (programSpecification != null);
}

Fixed version (ground truth):
@Override public Boolean apply(AppMds mds) throws Exception {
  ApplicationSpecification appSpec=getApplicationSpec(mds,id.getApplication());
  if (appSpec == null) {
    return false;
  }
  ProgramSpecification programSpecification=null;
  try {
    if (type == ProgramType.FLOW) {
      programSpecification=getFlowSpecOrFail(id,appSpec);
    }
 else     if (type == ProgramType.PROCEDURE) {
      programSpecification=getProcedureSpecOrFail(id,appSpec);
    }
 else     if (type == ProgramType.SERVICE) {
      programSpecification=getServiceSpecOrFail(id,appSpec);
    }
 else     if (type == ProgramType.WORKFLOW) {
      programSpecification=appSpec.getWorkflows().get(id.getId());
    }
 else     if (type == ProgramType.MAPREDUCE) {
      programSpecification=appSpec.getMapReduce().get(id.getId());
    }
 else     if (type == ProgramType.SPARK) {
      programSpecification=appSpec.getSpark().get(id.getId());
    }
 else     if (type == ProgramType.WEBAPP) {
    }
 else {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
 catch (  NoSuchElementException e) {
    programSpecification=null;
  }
catch (  Exception e) {
    Throwables.propagate(e);
  }
  return (programSpecification != null);
}
Program: 7486
Project: 7486
Buggy source:
@Override public List<ProgramSpecification> getDeletedProgramSpecifications(final Id.Application id,ApplicationSpecification appSpec){
  ApplicationMeta existing=txnl.executeUnchecked(new TransactionExecutor.Function<AppMds,ApplicationMeta>(){
    @Override public ApplicationMeta apply(    AppMds mds) throws Exception {
      return mds.apps.getApplication(id.getAccountId(),id.getId());
    }
  }
);
  List<ProgramSpecification> deletedProgramSpecs=Lists.newArrayList();
  if (existing != null) {
    ApplicationSpecification existingAppSpec=existing.getSpec();
    ImmutableMap<String,ProgramSpecification> existingSpec=new ImmutableMap.Builder<String,ProgramSpecification>().putAll(existingAppSpec.getMapReduce()).putAll(existingAppSpec.getWorkflows()).putAll(existingAppSpec.getFlows()).putAll(existingAppSpec.getProcedures()).putAll(existingAppSpec.getServices()).build();
    ImmutableMap<String,ProgramSpecification> newSpec=new ImmutableMap.Builder<String,ProgramSpecification>().putAll(appSpec.getMapReduce()).putAll(appSpec.getWorkflows()).putAll(appSpec.getFlows()).putAll(appSpec.getProcedures()).putAll(appSpec.getServices()).build();
    MapDifference<String,ProgramSpecification> mapDiff=Maps.difference(existingSpec,newSpec);
    deletedProgramSpecs.addAll(mapDiff.entriesOnlyOnLeft().values());
  }
  return deletedProgramSpecs;
}

Fixed version (ground truth):
@Override public List<ProgramSpecification> getDeletedProgramSpecifications(final Id.Application id,ApplicationSpecification appSpec){
  ApplicationMeta existing=txnl.executeUnchecked(new TransactionExecutor.Function<AppMds,ApplicationMeta>(){
    @Override public ApplicationMeta apply(    AppMds mds) throws Exception {
      return mds.apps.getApplication(id.getAccountId(),id.getId());
    }
  }
);
  List<ProgramSpecification> deletedProgramSpecs=Lists.newArrayList();
  if (existing != null) {
    ApplicationSpecification existingAppSpec=existing.getSpec();
    ImmutableMap<String,ProgramSpecification> existingSpec=new ImmutableMap.Builder<String,ProgramSpecification>().putAll(existingAppSpec.getMapReduce()).putAll(existingAppSpec.getSpark()).putAll(existingAppSpec.getWorkflows()).putAll(existingAppSpec.getFlows()).putAll(existingAppSpec.getProcedures()).putAll(existingAppSpec.getServices()).build();
    ImmutableMap<String,ProgramSpecification> newSpec=new ImmutableMap.Builder<String,ProgramSpecification>().putAll(appSpec.getMapReduce()).putAll(existingAppSpec.getSpark()).putAll(appSpec.getWorkflows()).putAll(appSpec.getFlows()).putAll(appSpec.getProcedures()).putAll(appSpec.getServices()).build();
    MapDifference<String,ProgramSpecification> mapDiff=Maps.difference(existingSpec,newSpec);
    deletedProgramSpecs.addAll(mapDiff.entriesOnlyOnLeft().values());
  }
  return deletedProgramSpecs;
}
Program: 7487
Project: 7487
Buggy source:
/** 
 * Stops the Spark program by calling   {@link org.apache.spark.SparkContext#stop()}
 */
public static void stopSparkProgram(){
  if (scalaProgramFlag) {
    ((org.apache.spark.SparkContext)getSparkContext().getOriginalSparkContext()).stop();
  }
 else {
    ((org.apache.spark.api.java.JavaSparkContext)getSparkContext().getOriginalSparkContext()).stop();
  }
}

Fixed version (ground truth):
/** 
 * Stops the Spark program by calling   {@link org.apache.spark.SparkContext#stop()}
 */
public static void stopSparkProgram(){
  sparkContextStopBugFixer();
  if (isScalaProgram()) {
    ((org.apache.spark.SparkContext)getSparkContext().getOriginalSparkContext()).stop();
  }
 else {
    ((org.apache.spark.api.java.JavaSparkContext)getSparkContext().getOriginalSparkContext()).stop();
  }
}
Program: 7488
Project: 7488
Buggy source:
/** 
 * Sets the   {@link SparkContext} to {@link JavaSparkContext} or to {@link ScalaSparkContext} depending on whetherthe user class implements  {@link JavaSparkProgram} or {@link ScalaSparkProgram}
 */
public void setSparkContext(){
  if (JavaSparkProgram.class.isAssignableFrom(userProgramClass)) {
    sparkContext=new JavaSparkContext();
  }
 else   if (ScalaSparkProgram.class.isAssignableFrom(userProgramClass)) {
    sparkContext=new ScalaSparkContext();
    scalaProgramFlag=true;
  }
 else {
    String error="String_Node_Str";
    throw new IllegalArgumentException(error);
  }
}

Fixed version (ground truth):
/** 
 * Sets the   {@link SparkContext} to {@link JavaSparkContext} or to {@link ScalaSparkContext} depending on whetherthe user class implements  {@link JavaSparkProgram} or {@link ScalaSparkProgram}
 */
void setSparkContext(){
  if (JavaSparkProgram.class.isAssignableFrom(userProgramClass)) {
    sparkContext=new JavaSparkContext();
  }
 else   if (ScalaSparkProgram.class.isAssignableFrom(userProgramClass)) {
    sparkContext=new ScalaSparkContext();
    setScalaProgram(true);
  }
 else {
    String error="String_Node_Str";
    throw new IllegalArgumentException(error);
  }
}
Program: 7489
Project: 7489
Buggy source:
/** 
 * Constructor
 * @param args the command line arguments
 * @throws RuntimeException if the user's program class is not found
 */
public SparkProgramWrapper(String[] args){
  arguments=validateArgs(args);
  try {
    userProgramClass=Class.forName(arguments[0],true,Thread.currentThread().getContextClassLoader());
  }
 catch (  ClassNotFoundException cnfe) {
    LOG.warn("String_Node_Str",arguments[0],cnfe);
    throw Throwables.propagate(cnfe);
  }
  setSparkContext();
}

Fixed version (ground truth):
/** 
 * Constructor
 * @param args the command line arguments
 * @throws RuntimeException if the user's program class is not found
 */
private SparkProgramWrapper(String[] args){
  arguments=validateArgs(args);
  try {
    userProgramClass=Class.forName(arguments[0],true,Thread.currentThread().getContextClassLoader());
  }
 catch (  ClassNotFoundException cnfe) {
    LOG.warn("String_Node_Str",arguments[0],cnfe);
    throw Throwables.propagate(cnfe);
  }
  setSparkContext();
}
Program: 7490
Project: 7490
Buggy source:
/** 
 * Stops the Spark program by calling   {@link org.apache.spark.SparkContext#stop()}
 */
public static void stopSparkProgram(){
  if (scalaProgramFlag) {
    ((org.apache.spark.SparkContext)getSparkContext().getOriginalSparkContext()).stop();
  }
 else {
    ((org.apache.spark.api.java.JavaSparkContext)getSparkContext().getOriginalSparkContext()).stop();
  }
}

Fixed version (ground truth):
/** 
 * Stops the Spark program by calling   {@link org.apache.spark.SparkContext#stop()}
 */
public static void stopSparkProgram(){
  sparkContextStopBugFixer();
  if (isScalaProgram()) {
    ((org.apache.spark.SparkContext)getSparkContext().getOriginalSparkContext()).stop();
  }
 else {
    ((org.apache.spark.api.java.JavaSparkContext)getSparkContext().getOriginalSparkContext()).stop();
  }
}
Program: 7491
Project: 7491
Buggy source:
/** 
 * Sets the   {@link SparkContext} to {@link JavaSparkContext} or to {@link ScalaSparkContext} depending on whetherthe user class implements  {@link JavaSparkProgram} or {@link ScalaSparkProgram}
 */
public void setSparkContext(){
  if (JavaSparkProgram.class.isAssignableFrom(userProgramClass)) {
    sparkContext=new JavaSparkContext();
  }
 else   if (ScalaSparkProgram.class.isAssignableFrom(userProgramClass)) {
    sparkContext=new ScalaSparkContext();
    scalaProgramFlag=true;
  }
 else {
    String error="String_Node_Str";
    throw new IllegalArgumentException(error);
  }
}

Fixed version (ground truth):
/** 
 * Sets the   {@link SparkContext} to {@link JavaSparkContext} or to {@link ScalaSparkContext} depending on whetherthe user class implements  {@link JavaSparkProgram} or {@link ScalaSparkProgram}
 */
void setSparkContext(){
  if (JavaSparkProgram.class.isAssignableFrom(userProgramClass)) {
    sparkContext=new JavaSparkContext();
  }
 else   if (ScalaSparkProgram.class.isAssignableFrom(userProgramClass)) {
    sparkContext=new ScalaSparkContext();
    setScalaProgram(true);
  }
 else {
    String error="String_Node_Str";
    throw new IllegalArgumentException(error);
  }
}
Program: 7492
Project: 7492
Buggy source:
/** 
 * Constructor
 * @param args the command line arguments
 * @throws RuntimeException if the user's program class is not found
 */
public SparkProgramWrapper(String[] args){
  arguments=validateArgs(args);
  try {
    userProgramClass=Class.forName(arguments[0],true,Thread.currentThread().getContextClassLoader());
  }
 catch (  ClassNotFoundException cnfe) {
    LOG.warn("String_Node_Str",arguments[0],cnfe);
    throw Throwables.propagate(cnfe);
  }
  setSparkContext();
}

Fixed version (ground truth):
/** 
 * Constructor
 * @param args the command line arguments
 * @throws RuntimeException if the user's program class is not found
 */
private SparkProgramWrapper(String[] args){
  arguments=validateArgs(args);
  try {
    userProgramClass=Class.forName(arguments[0],true,Thread.currentThread().getContextClassLoader());
  }
 catch (  ClassNotFoundException cnfe) {
    LOG.warn("String_Node_Str",arguments[0],cnfe);
    throw Throwables.propagate(cnfe);
  }
  setSparkContext();
}
Program: 7493
Project: 7493
Buggy source:
/** 
 * Stops the Spark program by calling   {@link org.apache.spark.SparkContext#stop()}
 */
public static void stopSparkProgram(){
  if (scalaJobFlag) {
    ((org.apache.spark.SparkContext)getSparkContext().getOriginalSparkContext()).stop();
  }
 else {
    ((org.apache.spark.api.java.JavaSparkContext)getSparkContext().getOriginalSparkContext()).stop();
  }
}

Fixed version (ground truth):
/** 
 * Stops the Spark program by calling   {@link org.apache.spark.SparkContext#stop()}
 */
public static void stopSparkProgram(){
  if (scalaProgramFlag) {
    ((org.apache.spark.SparkContext)getSparkContext().getOriginalSparkContext()).stop();
  }
 else {
    ((org.apache.spark.api.java.JavaSparkContext)getSparkContext().getOriginalSparkContext()).stop();
  }
}
Program: 7494
Project: 7494
Buggy source:
/** 
 * Sets the   {@link SparkContext} to {@link JavaSparkContext} or to {@link ScalaSparkContext} depending on whetherthe user class implements  {@link JavaSparkProgram} or {@link ScalaSparkProgram}
 */
public void setSparkContext(){
  if (JavaSparkProgram.class.isAssignableFrom(userJobClass)) {
    sparkContext=new JavaSparkContext();
  }
 else   if (ScalaSparkProgram.class.isAssignableFrom(userJobClass)) {
    sparkContext=new ScalaSparkContext();
    scalaJobFlag=true;
  }
 else {
    String error="String_Node_Str";
    throw new IllegalArgumentException(error);
  }
}

Fixed version (ground truth):
/** 
 * Sets the   {@link SparkContext} to {@link JavaSparkContext} or to {@link ScalaSparkContext} depending on whetherthe user class implements  {@link JavaSparkProgram} or {@link ScalaSparkProgram}
 */
public void setSparkContext(){
  if (JavaSparkProgram.class.isAssignableFrom(userProgramClass)) {
    sparkContext=new JavaSparkContext();
  }
 else   if (ScalaSparkProgram.class.isAssignableFrom(userProgramClass)) {
    sparkContext=new ScalaSparkContext();
    scalaProgramFlag=true;
  }
 else {
    String error="String_Node_Str";
    throw new IllegalArgumentException(error);
  }
}
Program: 7495
Project: 7495
Buggy source:
/** 
 * @param sparkProgramSuccessful a boolean to which the jobSuccess status will be set to
 */
public static void setSparkProgramSuccessful(boolean sparkProgramSuccessful){
  SparkProgramWrapper.sparkProgramSuccessful=sparkProgramSuccessful;
}

Fixed version (ground truth):
/** 
 * @param sparkProgramSuccessful a boolean to which the programSuccess status will be set to
 */
public static void setSparkProgramSuccessful(boolean sparkProgramSuccessful){
  SparkProgramWrapper.sparkProgramSuccessful=sparkProgramSuccessful;
}
Program: 7496
Project: 7496
Buggy source:
public static void main(String[] args){
  new SparkProgramWrapper(args).instantiateUserJobClass();
}

Fixed version (ground truth):
public static void main(String[] args){
  new SparkProgramWrapper(args).instantiateUserProgramClass();
}
Program: 7497
Project: 7497
Buggy source:
/** 
 * Extracts arguments belonging to the user's job class
 * @return String[] of arguments with which user's job class should be called
 */
private String[] extractUserArgs(){
  String[] userJobArgs=new String[(arguments.length - JOB_WRAPPER_ARGUMENTS_SIZE)];
  System.arraycopy(arguments,JOB_WRAPPER_ARGUMENTS_SIZE,userJobArgs,0,(arguments.length - JOB_WRAPPER_ARGUMENTS_SIZE));
  return userJobArgs;
}

Fixed version (ground truth):
/** 
 * Extracts arguments belonging to the user's program class
 * @return String[] of arguments with which user's program class should be called
 */
private String[] extractUserArgs(){
  String[] userProgramArgs=new String[(arguments.length - PROGRAM_WRAPPER_ARGUMENTS_SIZE)];
  System.arraycopy(arguments,PROGRAM_WRAPPER_ARGUMENTS_SIZE,userProgramArgs,0,(arguments.length - PROGRAM_WRAPPER_ARGUMENTS_SIZE));
  return userProgramArgs;
}
Program: 7498
Project: 7498
Buggy source:
/** 
 * Constructor
 * @param args the command line arguments
 * @throws RuntimeException if the user's job class is not found
 */
public SparkProgramWrapper(String[] args){
  arguments=validateArgs(args);
  try {
    userJobClass=Class.forName(arguments[0],true,Thread.currentThread().getContextClassLoader());
  }
 catch (  ClassNotFoundException cnfe) {
    LOG.warn("String_Node_Str",arguments[0],cnfe);
    throw Throwables.propagate(cnfe);
  }
  setSparkContext();
}

Fixed version (ground truth):
/** 
 * Constructor
 * @param args the command line arguments
 * @throws RuntimeException if the user's program class is not found
 */
public SparkProgramWrapper(String[] args){
  arguments=validateArgs(args);
  try {
    userProgramClass=Class.forName(arguments[0],true,Thread.currentThread().getContextClassLoader());
  }
 catch (  ClassNotFoundException cnfe) {
    LOG.warn("String_Node_Str",arguments[0],cnfe);
    throw Throwables.propagate(cnfe);
  }
  setSparkContext();
}
Program: 7499
Project: 7499
Buggy source:
/** 
 * Validates command line arguments being passed Expects at least   {@link SparkProgramWrapper#JOB_WRAPPER_ARGUMENTS_SIZE} command line arguments to be present
 * @param arguments String[] the arguments
 * @return String[] if the command line arguments are sufficient else throws a {@link RuntimeException}
 * @throws IllegalArgumentException if the required numbers of command line arguments were not present
 */
private String[] validateArgs(String[] arguments){
  if (arguments.length < JOB_WRAPPER_ARGUMENTS_SIZE) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  return arguments;
}

Fixed version (ground truth):
/** 
 * Validates command line arguments being passed Expects at least   {@link SparkProgramWrapper#PROGRAM_WRAPPER_ARGUMENTS_SIZE} command line arguments to be present
 * @param arguments String[] the arguments
 * @return String[] if the command line arguments are sufficient else throws a {@link RuntimeException}
 * @throws IllegalArgumentException if the required numbers of command line arguments were not present
 */
private String[] validateArgs(String[] arguments){
  if (arguments.length < PROGRAM_WRAPPER_ARGUMENTS_SIZE) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  return arguments;
}
Program: 7500
Project: 7500
Buggy source:
/** 
 * Sets the   {@link SparkContext} to {@link JavaSparkContext} or to {@link ScalaSparkContext} depending on whetherthe user class implements  {@link JavaSparkJob} or {@link ScalaSparkJob}
 */
public void setSparkContext(){
  if (JavaSparkJob.class.isAssignableFrom(userJobClass)) {
    sparkContext=new JavaSparkContext();
  }
 else   if (ScalaSparkJob.class.isAssignableFrom(userJobClass)) {
    sparkContext=new ScalaSparkContext();
    scalaJobFlag=true;
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Sets the   {@link SparkContext} to {@link JavaSparkContext} or to {@link ScalaSparkContext} depending on whetherthe user class implements  {@link JavaSparkProgram} or {@link ScalaSparkProgram}
 */
public void setSparkContext(){
  if (JavaSparkProgram.class.isAssignableFrom(userJobClass)) {
    sparkContext=new JavaSparkContext();
  }
 else   if (ScalaSparkProgram.class.isAssignableFrom(userJobClass)) {
    sparkContext=new ScalaSparkContext();
    scalaJobFlag=true;
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
}
Program: 7501
Project: 7501
Buggy source:
/** 
 * Sets the   {@link SparkContext} to {@link JavaSparkContext} or to {@link ScalaSparkContext} depending on whetherthe user class implements  {@link JavaSparkProgram} or {@link ScalaSparkProgram}
 */
public void setSparkContext(){
  if (JavaSparkProgram.class.isAssignableFrom(userJobClass)) {
    sparkContext=new JavaSparkContext();
  }
 else   if (ScalaSparkProgram.class.isAssignableFrom(userJobClass)) {
    sparkContext=new ScalaSparkContext();
    scalaJobFlag=true;
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Sets the   {@link SparkContext} to {@link JavaSparkContext} or to {@link ScalaSparkContext} depending on whetherthe user class implements  {@link JavaSparkProgram} or {@link ScalaSparkProgram}
 */
public void setSparkContext(){
  if (JavaSparkProgram.class.isAssignableFrom(userJobClass)) {
    sparkContext=new JavaSparkContext();
  }
 else   if (ScalaSparkProgram.class.isAssignableFrom(userJobClass)) {
    sparkContext=new ScalaSparkContext();
    scalaJobFlag=true;
  }
 else {
    String error="String_Node_Str";
    throw new IllegalArgumentException(error);
  }
}
Program: 7502
Project: 7502
Buggy source:
/** 
 * Gets information about a service.
 * @param appId ID of the application that the service belongs to
 * @param serviceId ID of the service
 * @return {@link ServiceMeta} representing the service.
 * @throws IOException if a network error occurred
 */
public ServiceMeta get(String appId,String serviceId) throws IOException {
  URL url=config.resolveURL(String.format("String_Node_Str",appId,serviceId));
  HttpResponse response=restClient.execute(HttpMethod.GET,url);
  return ObjectResponse.fromJsonBody(response,ServiceMeta.class).getResponseObject();
}

Fixed version (ground truth):
/** 
 * Gets information about a service.
 * @param appId ID of the application that the service belongs to
 * @param serviceId ID of the service
 * @return {@link ServiceMeta} representing the service.
 * @throws IOException if a network error occurred
 */
public ServiceMeta get(String appId,String serviceId) throws IOException {
  URL url=config.resolveURL(String.format("String_Node_Str",appId,serviceId));
  HttpResponse response=restClient.execute(HttpMethod.GET,url,config.getAccessToken());
  return ObjectResponse.fromJsonBody(response,ServiceMeta.class).getResponseObject();
}
Program: 7503
Project: 7503
Buggy source:
/** 
 * Gets the configuration of a stream.
 * @param streamId ID of the stream
 * @throws IOException if a network error occurred
 * @throws StreamNotFoundException if the stream was not found
 */
public StreamProperties getConfig(String streamId) throws IOException, StreamNotFoundException {
  URL url=config.resolveURL(String.format("String_Node_Str",streamId));
  HttpResponse response=restClient.execute(HttpMethod.GET,url,HttpURLConnection.HTTP_NOT_FOUND);
  if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
    throw new StreamNotFoundException(streamId);
  }
  return ObjectResponse.fromJsonBody(response,StreamProperties.class).getResponseObject();
}

Fixed version (ground truth):
/** 
 * Gets the configuration of a stream.
 * @param streamId ID of the stream
 * @throws IOException if a network error occurred
 * @throws StreamNotFoundException if the stream was not found
 */
public StreamProperties getConfig(String streamId) throws IOException, StreamNotFoundException {
  URL url=config.resolveURL(String.format("String_Node_Str",streamId));
  HttpResponse response=restClient.execute(HttpMethod.GET,url,config.getAccessToken(),HttpURLConnection.HTTP_NOT_FOUND);
  if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
    throw new StreamNotFoundException(streamId);
  }
  return ObjectResponse.fromJsonBody(response,StreamProperties.class).getResponseObject();
}
Program: 7505
Project: 7505
Buggy source:
@Override public void close() throws IOException {
  flush();
  avroFileWriter.close();
}

Fixed version (ground truth):
@Override public void close() throws IOException {
  if (!closed.compareAndSet(false,true)) {
    return;
  }
  flush();
  avroFileWriter.close();
}
Program: 7506
Project: 7506
Buggy source:
@Override public void close() throws IOException {
  flush();
  avroFileWriter.close();
}

Fixed version (ground truth):
@Override public void close() throws IOException {
  if (!closed.compareAndSet(false,true)) {
    return;
  }
  flush();
  avroFileWriter.close();
}
Program: 7508
Project: 7508
Buggy source:
private Location createFile(Location path) throws Exception {
  Location parent=Locations.getParent(path);
  parent.mkdirs();
  path.createNew();
  Assert.assertTrue(path.exists());
  return path;
}

Fixed version (ground truth):
private Location createFile(Location path) throws Exception {
  Location parent=Locations.getParent(path);
  Assert.assertNotNull(parent);
  parent.mkdirs();
  path.createNew();
  Assert.assertTrue(path.exists());
  return path;
}