nus-yam/ex-repair huggingface dataset:
Program: 7434
Project: 7434
Buggy source:
@Test public void testingMetricsWithRunIds() throws Exception {
  String runId1="String_Node_Str";
  String runId2="String_Node_Str";
  String runId3="String_Node_Str";
  MetricsCollector collector1=collectionService.getCollector(MetricsScope.USER,"String_Node_Str",runId1);
  collector1.increment("String_Node_Str",1);
  MetricsCollector collector2=collectionService.getCollector(MetricsScope.USER,"String_Node_Str",runId2);
  collector2.increment("String_Node_Str",2);
  MetricsCollector collector3=collectionService.getCollector(MetricsScope.USER,"String_Node_Str",runId3);
  collector3.gauge("String_Node_Str",10);
  TimeUnit.SECONDS.sleep(2);
  String serviceRequest="String_Node_Str" + runId2 + "String_Node_Str";
  String serviceRequestInvalidId="String_Node_Str";
  String serviceRequestTotal="String_Node_Str";
  String mapreduceMetric="String_Node_Str" + runId3 + "String_Node_Str";
  testSingleMetric(serviceRequest,2);
  testSingleMetric(serviceRequestInvalidId,0);
  testSingleMetric(serviceRequestTotal,3);
  testSingleMetric(mapreduceMetric,10);
}

Fixed version (ground truth):
@Test public void testingMetricsWithRunIds() throws Exception {
  String runId1="String_Node_Str";
  String runId2="String_Node_Str";
  String runId3="String_Node_Str";
  MetricsCollector collector1=collectionService.getCollector(MetricsScope.USER,"String_Node_Str",runId1);
  collector1.increment("String_Node_Str",1);
  MetricsCollector collector2=collectionService.getCollector(MetricsScope.USER,"String_Node_Str",runId2);
  collector2.increment("String_Node_Str",2);
  MetricsCollector collector3=collectionService.getCollector(MetricsScope.USER,"String_Node_Str",runId3);
  collector3.gauge("String_Node_Str",10);
  MetricsCollector collector4=collectionService.getCollector(MetricsScope.USER,"String_Node_Str",runId3);
  collector4.gauge("String_Node_Str",10);
  TimeUnit.SECONDS.sleep(2);
  String serviceRequest="String_Node_Str" + runId2 + "String_Node_Str";
  String serviceRequestInvalidId="String_Node_Str";
  String serviceRequestTotal="String_Node_Str";
  String mappersMetric="String_Node_Str" + runId3 + "String_Node_Str";
  String reducersMetric="String_Node_Str" + runId3 + "String_Node_Str";
  String mapredMetric="String_Node_Str" + runId3 + "String_Node_Str";
  testSingleMetric(serviceRequest,2);
  testSingleMetric(serviceRequestInvalidId,0);
  testSingleMetric(serviceRequestTotal,3);
  testSingleMetric(mappersMetric,10);
  testSingleMetric(reducersMetric,10);
  testSingleMetric(mapredMetric,20);
}
Program: 7436
Project: 7436
Buggy source:
@Override public void onFailure(Object inputObject,InputContext inputContext,FailureReason reason,InputAcknowledger inputAcknowledger){
  LOG.warn("String_Node_Str",flowletContext,reason.getMessage(),input,reason.getCause());
  FailurePolicy failurePolicy;
  try {
    flowletContext.getProgramMetrics().increment("String_Node_Str",1);
    failurePolicy=txCallback.onFailure(inputObject,inputContext,reason);
    if (failurePolicy == null) {
      failurePolicy=FailurePolicy.RETRY;
      LOG.info("String_Node_Str",failurePolicy);
    }
  }
 catch (  Throwable t) {
    LOG.error("String_Node_Str",flowletContext,t);
    failurePolicy=FailurePolicy.RETRY;
  }
  if (input.getRetry() >= processEntry.getProcessSpec().getProcessMethod().getMaxRetries()) {
    LOG.info("String_Node_Str",input);
    failurePolicy=FailurePolicy.IGNORE;
  }
  if (failurePolicy == FailurePolicy.RETRY) {
    FlowletProcessEntry retryEntry=processEntry.isRetry() ? processEntry : FlowletProcessEntry.create(processEntry.getProcessSpec(),new ProcessSpecification<T>(new SingleItemQueueReader<T>(input),processEntry.getProcessSpec().getProcessMethod(),null));
    processQueue.offer(retryEntry);
  }
 else   if (failurePolicy == FailurePolicy.IGNORE) {
    try {
      gaugeEventProcessed(input.getQueueName());
      inputAcknowledger.ack();
    }
 catch (    Throwable t) {
      LOG.error("String_Node_Str",flowletContext,t);
    }
 finally {
      enqueueEntry();
      inflight.decrementAndGet();
    }
  }
}

Fixed version (ground truth):
@Override public void onFailure(Object inputObject,InputContext inputContext,FailureReason reason,InputAcknowledger inputAcknowledger){
  LOG.warn("String_Node_Str",flowletContext,reason.getMessage(),input,reason.getCause());
  FailurePolicy failurePolicy;
  try {
    flowletContext.getProgramMetrics().increment("String_Node_Str",1);
    failurePolicy=txCallback.onFailure(inputObject,inputContext,reason);
    if (failurePolicy == null) {
      failurePolicy=FailurePolicy.RETRY;
      LOG.info("String_Node_Str",failurePolicy);
    }
  }
 catch (  Throwable t) {
    LOG.error("String_Node_Str",flowletContext,t);
    failurePolicy=FailurePolicy.RETRY;
  }
  if (input.getRetry() >= processEntry.getProcessSpec().getProcessMethod().getMaxRetries()) {
    LOG.info("String_Node_Str",input);
    failurePolicy=FailurePolicy.IGNORE;
  }
  if (failurePolicy == FailurePolicy.RETRY) {
    FlowletProcessEntry retryEntry=processEntry.isRetry() ? processEntry : FlowletProcessEntry.create(processEntry.getProcessSpec(),new ProcessSpecification<T>(new SingleItemQueueReader<T>(input),processEntry.getProcessSpec().getProcessMethod(),null));
    processQueue.offer(retryEntry);
  }
 else   if (failurePolicy == FailurePolicy.IGNORE) {
    try {
      gaugeEventProcessed(input.getQueueName());
      inputAcknowledger.ack();
    }
 catch (    Throwable t) {
      LOG.error("String_Node_Str",flowletContext,t);
    }
 finally {
      enqueueEntry();
    }
  }
}
Program: 7437
Project: 7437
Buggy source:
@Override protected void triggerShutdown(){
  LOG.info("String_Node_Str");
  runnerThread.interrupt();
}

Fixed version (ground truth):
@Override protected void triggerShutdown(){
  runThread.interrupt();
}
Program: 7438
Project: 7438
Buggy source:
FlowletProcessDriver(Flowlet flowlet,BasicFlowletContext flowletContext,Collection<ProcessSpecification> processSpecs,Callback txCallback,DataFabricFacade dataFabricFacade,Service serviceHook){
  this.flowlet=flowlet;
  this.flowletContext=flowletContext;
  this.loggingContext=flowletContext.getLoggingContext();
  this.processSpecs=processSpecs;
  this.txCallback=txCallback;
  this.dataFabricFacade=dataFabricFacade;
  this.serviceHook=serviceHook;
  this.inflight=new AtomicInteger(0);
  this.suspension=new AtomicReference<CountDownLatch>();
  this.suspendBarrier=new CyclicBarrier(2);
}

Fixed version (ground truth):
/** 
 * Copy constructor. Main purpose is to copy processQueue state. It's used for Flowlet suspend->resume.
 */
FlowletProcessDriver(FlowletProcessDriver other){
  Preconditions.checkArgument(other.state() == State.TERMINATED,"String_Node_Str");
  this.flowletContext=other.flowletContext;
  this.dataFabricFacade=other.dataFabricFacade;
  this.txCallback=other.txCallback;
  this.loggingContext=other.loggingContext;
  this.processQueue=new PriorityQueue<FlowletProcessEntry<?>>(other.processQueue.size());
  Iterables.addAll(processQueue,other.processQueue);
}
Program: 7439
Project: 7439
Buggy source:
@Override protected void startUp() throws Exception {
  runnerThread=Thread.currentThread();
  flowletContext.getProgramMetrics().increment("String_Node_Str",1);
  processExecutor=Executors.newSingleThreadExecutor(Threads.createDaemonThreadFactory(getServiceName() + "String_Node_Str"));
}

Fixed version (ground truth):
@Override protected void startUp() throws Exception {
  runThread=Thread.currentThread();
  processExecutor=Executors.newSingleThreadExecutor(Threads.createDaemonThreadFactory(getServiceName() + "String_Node_Str"));
}
Program: 7440
Project: 7440
Buggy source:
/** 
 * Creates a   {@link Runnable} for execution of calling flowlet process methods.
 */
private Runnable createProcessRunner(final BlockingQueue<FlowletProcessEntry<?>> processQueue,final List<FlowletProcessEntry<?>> processList,final ClassLoader classLoader){
  return new Runnable(){
    @Override public void run(){
      Thread.currentThread().setContextClassLoader(classLoader);
      for (      FlowletProcessEntry<?> entry : processList) {
        if (!handleProcessEntry(entry,processQueue)) {
          processQueue.offer(entry);
        }
      }
    }
  }
;
}

Fixed version (ground truth):
/** 
 * Creates a   {@link Runnable} for execution of calling flowlet process methods.
 */
private Runnable createProcessRunner(final PriorityQueue<FlowletProcessEntry<?>> processQueue,final List<FlowletProcessEntry<?>> processList,final ClassLoader classLoader){
  return new Runnable(){
    @Override public void run(){
      Thread.currentThread().setContextClassLoader(classLoader);
      for (      FlowletProcessEntry<?> entry : processList) {
        if (!handleProcessEntry(entry,processQueue)) {
          processQueue.offer(entry);
        }
      }
    }
  }
;
}
Program: 7442
Project: 7442
Buggy source:
@Override public void onSuccess(Object object,InputContext inputContext){
  try {
    gaugeEventProcessed(input.getQueueName());
    txCallback.onSuccess(object,inputContext);
  }
 catch (  Throwable t) {
    LOG.error("String_Node_Str",flowletContext,t);
  }
 finally {
    enqueueEntry();
    inflight.decrementAndGet();
  }
}

Fixed version (ground truth):
@Override public void onSuccess(Object object,InputContext inputContext){
  try {
    gaugeEventProcessed(input.getQueueName());
    txCallback.onSuccess(object,inputContext);
  }
 catch (  Throwable t) {
    LOG.error("String_Node_Str",flowletContext,t);
  }
 finally {
    enqueueEntry();
  }
}
Program: 7443
Project: 7443
Buggy source:
private void listenDriveState(FlowletProcessDriver driver){
  driver.addListener(new ServiceListenerAdapter(){
    @Override public void running(){
      started();
    }
    @Override public void failed(    Service.State from,    Throwable failure){
      LOG.error("String_Node_Str",failure);
      error(failure);
    }
    @Override public void terminated(    Service.State from){
      if (getState() != State.STOPPING) {
        LOG.warn("String_Node_Str");
        for (        ConsumerSupplier consumerSupplier : consumerSuppliers) {
          Closeables.closeQuietly(consumerSupplier);
        }
      }
    }
  }
,Threads.SAME_THREAD_EXECUTOR);
}

Fixed version (ground truth):
private void listenDriveState(FlowletRuntimeService driver){
  driver.addListener(new ServiceListenerAdapter(){
    @Override public void running(){
      started();
    }
    @Override public void failed(    Service.State from,    Throwable failure){
      LOG.error("String_Node_Str",failure);
      error(failure);
    }
    @Override public void terminated(    Service.State from){
      if (getState() != State.STOPPING) {
        LOG.warn("String_Node_Str");
        for (        ConsumerSupplier consumerSupplier : consumerSuppliers) {
          Closeables.closeQuietly(consumerSupplier);
        }
      }
    }
  }
,Threads.SAME_THREAD_EXECUTOR);
}
Program: 7444
Project: 7444
Buggy source:
/** 
 * Constructs an instance. The instance must be constructed before the flowlet driver starts.
 */
FlowletProgramController(String programName,String flowletName,BasicFlowletContext flowletContext,FlowletProcessDriver driver,Collection<ConsumerSupplier<?>> consumerSuppliers){
  super(programName + "String_Node_Str" + flowletName,flowletContext.getRunId());
  this.flowletContext=flowletContext;
  this.driver=driver;
  this.consumerSuppliers=consumerSuppliers;
  listenDriveState(driver);
}

Fixed version (ground truth):
/** 
 * Constructs an instance. The instance must be constructed before the flowlet driver starts.
 */
FlowletProgramController(String programName,String flowletName,BasicFlowletContext flowletContext,FlowletRuntimeService driver,Collection<ConsumerSupplier<?>> consumerSuppliers){
  super(programName + "String_Node_Str" + flowletName,flowletContext.getRunId());
  this.flowletContext=flowletContext;
  this.driver=driver;
  this.consumerSuppliers=consumerSuppliers;
  listenDriveState(driver);
}
Program: 7446
Project: 7446
Buggy source:
@ProcessInput(maxRetries=0) public void process(String str){
  if (!"String_Node_Str".equals(confTable.get(new Get("String_Node_Str","String_Node_Str")).getString("String_Node_Str"))) {
    throw new IllegalArgumentException("String_Node_Str");
  }
}

Fixed version (ground truth):
@ProcessInput(maxRetries=0) public void process(String str){
  if (!"String_Node_Str".equals(confTable.get(new Get("String_Node_Str","String_Node_Str")).getString("String_Node_Str"))) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  LOG.info("String_Node_Str",str);
}
Program: 7447
Project: 7447
Buggy source:
@Override public void initialize(FlowletContext context) throws FlowletException {
  confTable.put(new Put("String_Node_Str","String_Node_Str","String_Node_Str"));
}

Fixed version (ground truth):
@Override public void initialize(FlowletContext context) throws Exception {
  super.initialize(context);
  confTable.put(new Put("String_Node_Str","String_Node_Str","String_Node_Str"));
}
Program: 7448
Project: 7448
Buggy source:
@Tick(delay=10,unit=TimeUnit.MINUTES) public void generate(){
  output.emit("String_Node_Str");
}

Fixed version (ground truth):
@Tick(delay=10,unit=TimeUnit.MINUTES) public void generate(){
  output.emit("String_Node_Str" + getContext().getInstanceId());
}
Program: 7449
Project: 7449
Buggy source:
@Override public synchronized ClassLoader getClassLoader(){
  if (classLoader == null) {
    expandIfNeeded();
    try {
      classLoader=ProgramClassLoader.create(expandFolder,parentClassLoader);
    }
 catch (    IOException e) {
      throw Throwables.propagate(e);
    }
  }
  return classLoader;
}

Fixed version (ground truth):
@Override public synchronized ClassLoader getClassLoader(){
  if (classLoader == null) {
    expandIfNeeded();
    try {
      classLoader=ProgramClassLoader.create(expandFolder,parentClassLoader,processorType);
    }
 catch (    IOException e) {
      throw Throwables.propagate(e);
    }
  }
  return classLoader;
}
Program: 7451
Project: 7451
Buggy source:
/** 
 * 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();
}

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=loadUserSparkClass(arguments[0]);
  }
 catch (  ClassNotFoundException e) {
    LOG.error("String_Node_Str",arguments[0],e);
    throw Throwables.propagate(e);
  }
  setSparkContext();
}
Program: 7453
Project: 7453
Buggy source:
/** 
 * Copies the user submitted program jar
 * @param jobJarLocation {link Location} of the user's job
 * @param context        {@link BasicSparkContext} context of this job
 * @return {@link Location} where the program jar was copied
 * @throws IOException if failed to get the {@link Location#getInputStream()} or {@link Location#getOutputStream()}
 */
private Location copyProgramJar(Location jobJarLocation,BasicSparkContext context) throws IOException {
  Id.Program programId=context.getProgram().getId();
  Location programJarCopy=locationFactory.create(String.format("String_Node_Str",ProgramType.SPARK.name().toLowerCase(),programId.getAccountId(),programId.getApplicationId(),programId.getId(),context.getRunId().getId()));
  ByteStreams.copy(Locations.newInputSupplier(jobJarLocation),Locations.newOutputSupplier(programJarCopy));
  return programJarCopy;
}

Fixed version (ground truth):
/** 
 * Copies the user submitted program jar and flatten it out by expanding all jars in the "/" and "/lib" to top level.
 * @param jobJarLocation {link Location} of the user's job
 * @param context        {@link BasicSparkContext} context of this job
 * @return {@link Location} where the program jar was copied
 * @throws IOException if failed to get the {@link Location#getInputStream()} or {@link Location#getOutputStream()}
 */
private Location copyProgramJar(Location jobJarLocation,BasicSparkContext context) throws IOException {
  Id.Program programId=context.getProgram().getId();
  Location programJarCopy=locationFactory.create(String.format("String_Node_Str",ProgramType.SPARK.name().toLowerCase(),programId.getAccountId(),programId.getApplicationId(),programId.getId(),context.getRunId().getId()));
  Set<String> entries=Sets.newHashSet();
  JarInputStream programInput=new JarInputStream(jobJarLocation.getInputStream());
  try {
    Manifest manifest=getManifest(programInput,context.getProgram());
    JarOutputStream programOutput=new JarOutputStream(programJarCopy.getOutputStream(),manifest);
    try {
      JarEntry entry;
      while ((entry=programInput.getNextJarEntry()) != null) {
        String entryName=entry.getName();
        if (!entries.add(entryName)) {
          continue;
        }
        if (entryName.endsWith("String_Node_Str")) {
          int idx=entryName.indexOf('/');
          if (idx < 0 || entryName.indexOf('/',idx + 1) < 0) {
            copyJarContent(new JarInputStream(programInput),programOutput,entries);
            continue;
          }
        }
        programOutput.putNextEntry(entry);
        ByteStreams.copy(programInput,programOutput);
        programOutput.closeEntry();
      }
    }
  finally {
      Closeables.closeQuietly(programOutput);
    }
  }
  finally {
    Closeables.closeQuietly(programInput);
  }
  return programJarCopy;
}
Program: 7454
Project: 7454
Buggy source:
@Override protected void startUp() throws Exception {
  sparkHConf=new Configuration(hConf);
  final ClassLoader classLoader=new CombineClassLoader(Objects.firstNonNull(Thread.currentThread().getContextClassLoader(),ClassLoader.getSystemClassLoader()),ImmutableList.of(context.getProgram().getClassLoader()));
  sparkHConf.setClassLoader(classLoader);
  beforeSubmit();
  try {
    Location programJarCopy=copyProgramJar(programJarLocation,context);
    try {
      Transaction tx=txClient.startLong();
      try {
        SparkContextConfig.set(sparkHConf,context,cConf,tx,programJarCopy);
        Location dependencyJar=buildDependencyJar(context,SparkContextConfig.getHConf());
        try {
          sparkSubmitArgs=prepareSparkSubmitArgs(sparkSpecification,sparkHConf,programJarCopy,dependencyJar);
          LOG.info("String_Node_Str",context,Arrays.toString(sparkSubmitArgs));
          this.transaction=tx;
          this.cleanupTask=createCleanupTask(dependencyJar,programJarCopy);
        }
 catch (        Throwable t) {
          Locations.deleteQuietly(dependencyJar);
          throw Throwables.propagate(t);
        }
      }
 catch (      Throwable t) {
        Transactions.invalidateQuietly(txClient,tx);
        throw Throwables.propagate(t);
      }
    }
 catch (    Throwable t) {
      Locations.deleteQuietly(programJarCopy);
      throw Throwables.propagate(t);
    }
  }
 catch (  Throwable t) {
    LOG.error("String_Node_Str",context,t);
    throw Throwables.propagate(t);
  }
}

Fixed version (ground truth):
@Override protected void startUp() throws Exception {
  Configuration sparkHConf=new Configuration(hConf);
  beforeSubmit();
  try {
    Location programJarCopy=copyProgramJar(programJarLocation,context);
    try {
      Transaction tx=txClient.startLong();
      try {
        SparkContextConfig.set(sparkHConf,context,cConf,tx,programJarCopy);
        Location dependencyJar=buildDependencyJar(context,SparkContextConfig.getHConf());
        try {
          sparkSubmitArgs=prepareSparkSubmitArgs(sparkSpecification,sparkHConf,programJarCopy,dependencyJar);
          LOG.info("String_Node_Str",context,Arrays.toString(sparkSubmitArgs));
          this.transaction=tx;
          this.cleanupTask=createCleanupTask(dependencyJar,programJarCopy);
        }
 catch (        Throwable t) {
          Locations.deleteQuietly(dependencyJar);
          throw Throwables.propagate(t);
        }
      }
 catch (      Throwable t) {
        Transactions.invalidateQuietly(txClient,tx);
        throw Throwables.propagate(t);
      }
    }
 catch (    Throwable t) {
      Locations.deleteQuietly(programJarCopy);
      throw Throwables.propagate(t);
    }
  }
 catch (  Throwable t) {
    LOG.error("String_Node_Str",context,t);
    throw Throwables.propagate(t);
  }
}
Program: 7455
Project: 7455
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: 7456
Project: 7456
Buggy source:
private static void parseRunIdFromQueryParam(Map<String,List<String>> queryParams,MetricsRequestBuilder builder) throws MetricsPathException {
  if (queryParams.containsKey(RUN_ID)) {
    if (queryParams.size() > 1) {
      throw new MetricsPathException("String_Node_Str");
    }
    builder.setRunId(queryParams.get(RUN_ID).get(0));
  }
}

Fixed version (ground truth):
private static void parseRunIdFromQueryParam(Map<String,List<String>> queryParams,MetricsRequestBuilder builder) throws MetricsPathException {
  if (queryParams.containsKey(RUN_ID)) {
    if (queryParams.get(RUN_ID).size() > 1) {
      throw new MetricsPathException("String_Node_Str");
    }
    builder.setRunId(queryParams.get(RUN_ID).get(0));
  }
}
Program: 7457
Project: 7457
Buggy source:
/** 
 * Waits for an application to be deleted.
 * @param appId ID of the application to check
 * @param timeout time to wait before timing out
 * @param timeoutUnit time unit of timeout
 * @throws IOException if a network error occurred
 * @throws UnAuthorizedAccessTokenException if the request is not authorized successfully in the gateway server
 * @throws TimeoutException if the application was not yet deleted before {@code timeout} milliseconds
 * @throws InterruptedException if interrupted while waiting
 */
public void waitForDeleted(final String appId,long timeout,TimeUnit timeoutUnit) throws IOException, UnAuthorizedAccessTokenException, TimeoutException, InterruptedException {
  try {
    ProgramFlowUtil.waitFor(false,new Callable<Boolean>(){
      @Override public Boolean call() throws Exception {
        return exists(appId);
      }
    }
,timeout,timeoutUnit.toSeconds(1),timeoutUnit);
  }
 catch (  ExecutionException e) {
    Throwables.propagateIfPossible(e.getCause(),IOException.class,UnAuthorizedAccessTokenException.class);
  }
}

Fixed version (ground truth):
/** 
 * Waits for an application to be deleted.
 * @param appId ID of the application to check
 * @param timeout time to wait before timing out
 * @param timeoutUnit time unit of timeout
 * @throws IOException if a network error occurred
 * @throws UnAuthorizedAccessTokenException if the request is not authorized successfully in the gateway server
 * @throws TimeoutException if the application was not yet deleted before {@code timeout} milliseconds
 * @throws InterruptedException if interrupted while waiting
 */
public void waitForDeleted(final String appId,long timeout,TimeUnit timeoutUnit) throws IOException, UnAuthorizedAccessTokenException, TimeoutException, InterruptedException {
  try {
    ProgramFlowUtil.waitFor(false,new Callable<Boolean>(){
      @Override public Boolean call() throws Exception {
        return exists(appId);
      }
    }
,timeout,timeoutUnit,1,TimeUnit.SECONDS);
  }
 catch (  ExecutionException e) {
    Throwables.propagateIfPossible(e.getCause(),IOException.class,UnAuthorizedAccessTokenException.class);
  }
}
Program: 7458
Project: 7458
Buggy source:
/** 
 * Waits for an application to be deployed.
 * @param appId ID of the application to check
 * @param timeout time to wait before timing out
 * @param timeoutUnit time unit of timeout
 * @throws IOException if a network error occurred
 * @throws UnAuthorizedAccessTokenException if the request is not authorized successfully in the gateway server
 * @throws TimeoutException if the application was not yet deployed before {@code timeout} milliseconds
 * @throws InterruptedException if interrupted while waiting
 */
public void waitForDeployed(final String appId,long timeout,TimeUnit timeoutUnit) throws IOException, UnAuthorizedAccessTokenException, TimeoutException, InterruptedException {
  try {
    ProgramFlowUtil.waitFor(true,new Callable<Boolean>(){
      @Override public Boolean call() throws Exception {
        return exists(appId);
      }
    }
,timeout,timeoutUnit.toSeconds(1),timeoutUnit);
  }
 catch (  ExecutionException e) {
    Throwables.propagateIfPossible(e.getCause(),IOException.class,UnAuthorizedAccessTokenException.class);
  }
}

Fixed version (ground truth):
/** 
 * Waits for an application to be deployed.
 * @param appId ID of the application to check
 * @param timeout time to wait before timing out
 * @param timeoutUnit time unit of timeout
 * @throws IOException if a network error occurred
 * @throws UnAuthorizedAccessTokenException if the request is not authorized successfully in the gateway server
 * @throws TimeoutException if the application was not yet deployed before {@code timeout} milliseconds
 * @throws InterruptedException if interrupted while waiting
 */
public void waitForDeployed(final String appId,long timeout,TimeUnit timeoutUnit) throws IOException, UnAuthorizedAccessTokenException, TimeoutException, InterruptedException {
  try {
    ProgramFlowUtil.waitFor(true,new Callable<Boolean>(){
      @Override public Boolean call() throws Exception {
        return exists(appId);
      }
    }
,timeout,timeoutUnit,1,TimeUnit.SECONDS);
  }
 catch (  ExecutionException e) {
    Throwables.propagateIfPossible(e.getCause(),IOException.class,UnAuthorizedAccessTokenException.class);
  }
}
Program: 7459
Project: 7459
Buggy source:
/** 
 * Waits for a dataset to be deleted.
 * @param datasetName Name of the dataset to check
 * @param timeout time to wait before timing out
 * @param timeoutUnit time unit of timeout
 * @throws IOException if a network error occurred
 * @throws UnAuthorizedAccessTokenException if the request is not authorized successfully in the gateway server
 * @throws TimeoutException if the dataset was not yet deleted before {@code timeout} milliseconds
 * @throws InterruptedException if interrupted while waiting
 */
public void waitForDeleted(final String datasetName,long timeout,TimeUnit timeoutUnit) throws IOException, UnAuthorizedAccessTokenException, TimeoutException, InterruptedException {
  try {
    ProgramFlowUtil.waitFor(false,new Callable<Boolean>(){
      @Override public Boolean call() throws Exception {
        return exists(datasetName);
      }
    }
,timeout,timeoutUnit.toSeconds(1),timeoutUnit);
  }
 catch (  ExecutionException e) {
    Throwables.propagateIfPossible(e.getCause(),IOException.class,UnAuthorizedAccessTokenException.class);
  }
}

Fixed version (ground truth):
/** 
 * Waits for a dataset to be deleted.
 * @param datasetName Name of the dataset to check
 * @param timeout time to wait before timing out
 * @param timeoutUnit time unit of timeout
 * @throws IOException if a network error occurred
 * @throws UnAuthorizedAccessTokenException if the request is not authorized successfully in the gateway server
 * @throws TimeoutException if the dataset was not yet deleted before {@code timeout} milliseconds
 * @throws InterruptedException if interrupted while waiting
 */
public void waitForDeleted(final String datasetName,long timeout,TimeUnit timeoutUnit) throws IOException, UnAuthorizedAccessTokenException, TimeoutException, InterruptedException {
  try {
    ProgramFlowUtil.waitFor(false,new Callable<Boolean>(){
      @Override public Boolean call() throws Exception {
        return exists(datasetName);
      }
    }
,timeout,timeoutUnit,1,TimeUnit.SECONDS);
  }
 catch (  ExecutionException e) {
    Throwables.propagateIfPossible(e.getCause(),IOException.class,UnAuthorizedAccessTokenException.class);
  }
}
Program: 7460
Project: 7460
Buggy source:
/** 
 * Waits for a dataset to exist.
 * @param datasetName Name of the dataset to check
 * @param timeout time to wait before timing out
 * @param timeoutUnit time unit of timeout
 * @throws IOException if a network error occurred
 * @throws UnAuthorizedAccessTokenException if the request is not authorized successfully in the gateway server
 * @throws TimeoutException if the dataset was not yet existent before {@code timeout} milliseconds
 * @throws InterruptedException if interrupted while waiting
 */
public void waitForExists(final String datasetName,long timeout,TimeUnit timeoutUnit) throws IOException, UnAuthorizedAccessTokenException, TimeoutException, InterruptedException {
  try {
    ProgramFlowUtil.waitFor(true,new Callable<Boolean>(){
      @Override public Boolean call() throws Exception {
        return exists(datasetName);
      }
    }
,timeout,timeoutUnit.toSeconds(1),timeoutUnit);
  }
 catch (  ExecutionException e) {
    Throwables.propagateIfPossible(e.getCause(),IOException.class,UnAuthorizedAccessTokenException.class);
  }
}

Fixed version (ground truth):
/** 
 * Waits for a dataset to exist.
 * @param datasetName Name of the dataset to check
 * @param timeout time to wait before timing out
 * @param timeoutUnit time unit of timeout
 * @throws IOException if a network error occurred
 * @throws UnAuthorizedAccessTokenException if the request is not authorized successfully in the gateway server
 * @throws TimeoutException if the dataset was not yet existent before {@code timeout} milliseconds
 * @throws InterruptedException if interrupted while waiting
 */
public void waitForExists(final String datasetName,long timeout,TimeUnit timeoutUnit) throws IOException, UnAuthorizedAccessTokenException, TimeoutException, InterruptedException {
  try {
    ProgramFlowUtil.waitFor(true,new Callable<Boolean>(){
      @Override public Boolean call() throws Exception {
        return exists(datasetName);
      }
    }
,timeout,timeoutUnit,1,TimeUnit.SECONDS);
  }
 catch (  ExecutionException e) {
    Throwables.propagateIfPossible(e.getCause(),IOException.class,UnAuthorizedAccessTokenException.class);
  }
}
Program: 7461
Project: 7461
Buggy source:
/** 
 * Waits for a dataset module to be deleted.
 * @param moduleName Name of the dataset module to check
 * @param timeout time to wait before timing out
 * @param timeoutUnit time unit of timeout
 * @throws IOException if a network error occurred
 * @throws UnAuthorizedAccessTokenException if the request is not authorized successfully in the gateway server
 * @throws TimeoutException if the dataset module was not yet deleted before {@code timeout} milliseconds
 * @throws InterruptedException if interrupted while waiting
 */
public void waitForDeleted(final String moduleName,long timeout,TimeUnit timeoutUnit) throws IOException, UnAuthorizedAccessTokenException, TimeoutException, InterruptedException {
  try {
    ProgramFlowUtil.waitFor(false,new Callable<Boolean>(){
      @Override public Boolean call() throws Exception {
        return exists(moduleName);
      }
    }
,timeout,timeoutUnit.toSeconds(1),timeoutUnit);
  }
 catch (  ExecutionException e) {
    Throwables.propagateIfPossible(e.getCause(),IOException.class,UnAuthorizedAccessTokenException.class);
  }
}

Fixed version (ground truth):
/** 
 * Waits for a dataset module to be deleted.
 * @param moduleName Name of the dataset module to check
 * @param timeout time to wait before timing out
 * @param timeoutUnit time unit of timeout
 * @throws IOException if a network error occurred
 * @throws UnAuthorizedAccessTokenException if the request is not authorized successfully in the gateway server
 * @throws TimeoutException if the dataset module was not yet deleted before {@code timeout} milliseconds
 * @throws InterruptedException if interrupted while waiting
 */
public void waitForDeleted(final String moduleName,long timeout,TimeUnit timeoutUnit) throws IOException, UnAuthorizedAccessTokenException, TimeoutException, InterruptedException {
  try {
    ProgramFlowUtil.waitFor(false,new Callable<Boolean>(){
      @Override public Boolean call() throws Exception {
        return exists(moduleName);
      }
    }
,timeout,timeoutUnit,1,TimeUnit.SECONDS);
  }
 catch (  ExecutionException e) {
    Throwables.propagateIfPossible(e.getCause(),IOException.class,UnAuthorizedAccessTokenException.class);
  }
}
Program: 7462
Project: 7462
Buggy source:
/** 
 * Waits for a dataset module to exist.
 * @param moduleName Name of the dataset module to check
 * @param timeout time to wait before timing out
 * @param timeoutUnit time unit of timeout
 * @throws IOException if a network error occurred
 * @throws UnAuthorizedAccessTokenException if the request is not authorized successfully in the gateway server
 * @throws TimeoutException if the dataset module was not yet existent before {@code timeout} milliseconds
 * @throws InterruptedException if interrupted while waiting
 */
public void waitForExists(final String moduleName,long timeout,TimeUnit timeoutUnit) throws IOException, UnAuthorizedAccessTokenException, TimeoutException, InterruptedException {
  try {
    ProgramFlowUtil.waitFor(true,new Callable<Boolean>(){
      @Override public Boolean call() throws Exception {
        return exists(moduleName);
      }
    }
,timeout,timeoutUnit.toSeconds(1),timeoutUnit);
  }
 catch (  ExecutionException e) {
    Throwables.propagateIfPossible(e.getCause(),IOException.class,UnAuthorizedAccessTokenException.class);
  }
}

Fixed version (ground truth):
/** 
 * Waits for a dataset module to exist.
 * @param moduleName Name of the dataset module to check
 * @param timeout time to wait before timing out
 * @param timeoutUnit time unit of timeout
 * @throws IOException if a network error occurred
 * @throws UnAuthorizedAccessTokenException if the request is not authorized successfully in the gateway server
 * @throws TimeoutException if the dataset module was not yet existent before {@code timeout} milliseconds
 * @throws InterruptedException if interrupted while waiting
 */
public void waitForExists(final String moduleName,long timeout,TimeUnit timeoutUnit) throws IOException, UnAuthorizedAccessTokenException, TimeoutException, InterruptedException {
  try {
    ProgramFlowUtil.waitFor(true,new Callable<Boolean>(){
      @Override public Boolean call() throws Exception {
        return exists(moduleName);
      }
    }
,timeout,timeoutUnit,1,TimeUnit.SECONDS);
  }
 catch (  ExecutionException e) {
    Throwables.propagateIfPossible(e.getCause(),IOException.class,UnAuthorizedAccessTokenException.class);
  }
}
Program: 7463
Project: 7463
Buggy source:
/** 
 * Waits for a dataset type to be deleted.
 * @param moduleName Name of the dataset type to check
 * @param timeout time to wait before timing out
 * @param timeoutUnit time unit of timeout
 * @throws IOException if a network error occurred
 * @throws UnAuthorizedAccessTokenException if the request is not authorized successfully in the gateway server
 * @throws TimeoutException if the dataset type was not yet deleted before {@code timeout} milliseconds
 * @throws InterruptedException if interrupted while waiting
 */
public void waitForDeleted(final String moduleName,long timeout,TimeUnit timeoutUnit) throws IOException, UnAuthorizedAccessTokenException, TimeoutException, InterruptedException {
  try {
    ProgramFlowUtil.waitFor(false,new Callable<Boolean>(){
      @Override public Boolean call() throws Exception {
        return exists(moduleName);
      }
    }
,timeout,timeoutUnit.toSeconds(1),timeoutUnit);
  }
 catch (  ExecutionException e) {
    Throwables.propagateIfPossible(e.getCause(),IOException.class,UnAuthorizedAccessTokenException.class);
  }
}

Fixed version (ground truth):
/** 
 * Waits for a dataset type to be deleted.
 * @param moduleName Name of the dataset type to check
 * @param timeout time to wait before timing out
 * @param timeoutUnit time unit of timeout
 * @throws IOException if a network error occurred
 * @throws UnAuthorizedAccessTokenException if the request is not authorized successfully in the gateway server
 * @throws TimeoutException if the dataset type was not yet deleted before {@code timeout} milliseconds
 * @throws InterruptedException if interrupted while waiting
 */
public void waitForDeleted(final String moduleName,long timeout,TimeUnit timeoutUnit) throws IOException, UnAuthorizedAccessTokenException, TimeoutException, InterruptedException {
  try {
    ProgramFlowUtil.waitFor(false,new Callable<Boolean>(){
      @Override public Boolean call() throws Exception {
        return exists(moduleName);
      }
    }
,timeout,timeoutUnit,1,TimeUnit.SECONDS);
  }
 catch (  ExecutionException e) {
    Throwables.propagateIfPossible(e.getCause(),IOException.class,UnAuthorizedAccessTokenException.class);
  }
}
Program: 7464
Project: 7464
Buggy source:
/** 
 * Waits for a dataset type to exist.
 * @param typeName Name of the dataset type to check
 * @param timeout time to wait before timing out
 * @param timeoutUnit time unit of timeout
 * @throws IOException if a network error occurred
 * @throws UnAuthorizedAccessTokenException if the request is not authorized successfully in the gateway server
 * @throws TimeoutException if the dataset type was not yet existent before {@code timeout} milliseconds
 * @throws InterruptedException if interrupted while waiting
 */
public void waitForExists(final String typeName,long timeout,TimeUnit timeoutUnit) throws IOException, UnAuthorizedAccessTokenException, TimeoutException, InterruptedException {
  try {
    ProgramFlowUtil.waitFor(true,new Callable<Boolean>(){
      @Override public Boolean call() throws Exception {
        return exists(typeName);
      }
    }
,timeout,timeoutUnit.toSeconds(1),timeoutUnit);
  }
 catch (  ExecutionException e) {
    Throwables.propagateIfPossible(e.getCause(),IOException.class,UnAuthorizedAccessTokenException.class);
  }
}

Fixed version (ground truth):
/** 
 * Waits for a dataset type to exist.
 * @param typeName Name of the dataset type to check
 * @param timeout time to wait before timing out
 * @param timeoutUnit time unit of timeout
 * @throws IOException if a network error occurred
 * @throws UnAuthorizedAccessTokenException if the request is not authorized successfully in the gateway server
 * @throws TimeoutException if the dataset type was not yet existent before {@code timeout} milliseconds
 * @throws InterruptedException if interrupted while waiting
 */
public void waitForExists(final String typeName,long timeout,TimeUnit timeoutUnit) throws IOException, UnAuthorizedAccessTokenException, TimeoutException, InterruptedException {
  try {
    ProgramFlowUtil.waitFor(true,new Callable<Boolean>(){
      @Override public Boolean call() throws Exception {
        return exists(typeName);
      }
    }
,timeout,timeoutUnit,1,TimeUnit.SECONDS);
  }
 catch (  ExecutionException e) {
    Throwables.propagateIfPossible(e.getCause(),IOException.class,UnAuthorizedAccessTokenException.class);
  }
}
Program: 7465
Project: 7465
Buggy source:
/** 
 * Waits for a program to have a certain status.
 * @param appId ID of the application that the program belongs to
 * @param programType type of the program
 * @param programId name of the program
 * @param status the desired status
 * @param timeout how long to wait in milliseconds until timing out
 * @throws IOException if a network error occurred
 * @throws ProgramNotFoundException if the program with the specified name could not be found
 * @throws UnAuthorizedAccessTokenException if the request is not authorized successfully in the gateway server
 * @throws TimeoutException if the program did not achieve the desired program status before the timeout
 * @throws InterruptedException if interrupted while waiting for the desired program status
 */
public void waitForStatus(final String appId,final ProgramType programType,final String programId,String status,long timeout,TimeUnit timeoutUnit) throws UnAuthorizedAccessTokenException, IOException, ProgramNotFoundException, TimeoutException, InterruptedException {
  try {
    ProgramFlowUtil.waitFor(status,new Callable<String>(){
      @Override public String call() throws Exception {
        return getStatus(appId,programType,programId);
      }
    }
,timeout,timeoutUnit.toSeconds(1),timeoutUnit);
  }
 catch (  ExecutionException e) {
    Throwables.propagateIfPossible(e.getCause(),UnAuthorizedAccessTokenException.class);
    Throwables.propagateIfPossible(e.getCause(),ProgramNotFoundException.class);
    Throwables.propagateIfPossible(e.getCause(),IOException.class);
  }
}

Fixed version (ground truth):
/** 
 * Waits for a program to have a certain status.
 * @param appId ID of the application that the program belongs to
 * @param programType type of the program
 * @param programId name of the program
 * @param status the desired status
 * @param timeout how long to wait in milliseconds until timing out
 * @throws IOException if a network error occurred
 * @throws ProgramNotFoundException if the program with the specified name could not be found
 * @throws UnAuthorizedAccessTokenException if the request is not authorized successfully in the gateway server
 * @throws TimeoutException if the program did not achieve the desired program status before the timeout
 * @throws InterruptedException if interrupted while waiting for the desired program status
 */
public void waitForStatus(final String appId,final ProgramType programType,final String programId,String status,long timeout,TimeUnit timeoutUnit) throws UnAuthorizedAccessTokenException, IOException, ProgramNotFoundException, TimeoutException, InterruptedException {
  try {
    ProgramFlowUtil.waitFor(status,new Callable<String>(){
      @Override public String call() throws Exception {
        return getStatus(appId,programType,programId);
      }
    }
,timeout,timeoutUnit,1,TimeUnit.SECONDS);
  }
 catch (  ExecutionException e) {
    Throwables.propagateIfPossible(e.getCause(),UnAuthorizedAccessTokenException.class);
    Throwables.propagateIfPossible(e.getCause(),ProgramNotFoundException.class);
    Throwables.propagateIfPossible(e.getCause(),IOException.class);
  }
}
Program: 7466
Project: 7466
Buggy source:
/** 
 * Calls callable, waiting sleepDelay between each call, until it returns the desiredValue or the timeout has passed.
 * @param desiredValue the desired value to get from callable
 * @param callable the callable to check
 * @param timeout time until we timeout
 * @param sleepDelay time to wait between calls to callable
 * @param timeUnit unit of time for timeout and sleepDelay
 * @param < T > type of desiredValue
 * @throws TimeoutException if timeout has passed, but didn't get the desiredValue
 * @throws InterruptedException if something interrupted this waiting operation
 * @throws ExecutionException if there was an exception in calling the callable
 */
public static <T>void waitFor(T desiredValue,Callable<T> callable,long timeout,long sleepDelay,TimeUnit timeUnit) throws TimeoutException, InterruptedException, ExecutionException {
  long startTime=System.currentTimeMillis();
  long timeoutMs=timeUnit.toMillis(timeout);
  while (System.currentTimeMillis() - startTime < timeoutMs) {
    try {
      if (desiredValue.equals(callable.call())) {
        return;
      }
    }
 catch (    Exception e) {
      throw new ExecutionException(e);
    }
    Thread.sleep(sleepDelay);
  }
  throw new TimeoutException();
}

Fixed version (ground truth):
/** 
 * Calls callable, waiting sleepDelay between each call, until it returns the desiredValue or the timeout has passed.
 * @param desiredValue the desired value to get from callable
 * @param callable the callable to check
 * @param timeout time until we timeout
 * @param timeoutUnit unit of time for timeout
 * @param sleepDelay time to wait between calls to callable
 * @param sleepDelayUnit unit of time for sleepDelay
 * @param < T > type of desiredValue
 * @throws TimeoutException if timeout has passed, but didn't get the desiredValue
 * @throws InterruptedException if something interrupted this waiting operation
 * @throws ExecutionException if there was an exception in calling the callable
 */
public static <T>void waitFor(T desiredValue,Callable<T> callable,long timeout,TimeUnit timeoutUnit,long sleepDelay,TimeUnit sleepDelayUnit) throws TimeoutException, InterruptedException, ExecutionException {
  long sleepDelayMs=sleepDelayUnit.toMillis(sleepDelay);
  long startTime=System.currentTimeMillis();
  long timeoutMs=timeoutUnit.toMillis(timeout);
  while (System.currentTimeMillis() - startTime < timeoutMs) {
    try {
      if (desiredValue.equals(callable.call())) {
        return;
      }
    }
 catch (    Exception e) {
      throw new ExecutionException(e);
    }
    Thread.sleep(sleepDelayMs);
  }
  throw new TimeoutException();
}