nus-yam/ex-repair huggingface dataset:
Program: 161714
Project: 161714
Buggy source:
@Override protected void runHighPriorityTask(TaskWrapper task) throws InterruptedException {
  Worker w=null;
synchronized (workersLock) {
    if (!getShutdownFinishing()) {
synchronized (highPriorityWorkerAvailable.getModificationLock()) {
        highPriorityWorkerAvailable.add(!availableWorkers.isEmpty());
        trimList(highPriorityWorkerAvailable);
      }
      if (getCurrentPoolSize() >= getMaxPoolSize()) {
        w=getExistingWorker(Long.MAX_VALUE);
      }
 else {
        lastHighDelay=0;
        if (availableWorkers.isEmpty()) {
          w=makeNewWorker();
        }
 else {
          w=availableWorkers.removeFirst();
        }
      }
    }
  }
  if (w != null) {
    Clock.systemNanoTime();
    long executionDelay=task.getDelayEstimateInMillis();
    if (executionDelay <= 0) {
synchronized (highPriorityExecutionDelay.getModificationLock()) {
        highPriorityExecutionDelay.add(executionDelay * -1);
        trimList(highPriorityExecutionDelay);
      }
    }
    w.nextTask(task);
  }
}

Fixed version (ground truth):
@Override protected void runHighPriorityTask(TaskWrapper task) throws InterruptedException {
  Worker w=null;
synchronized (workersLock) {
    if (!getShutdownFinishing()) {
synchronized (highPriorityWorkerAvailable.getModificationLock()) {
        highPriorityWorkerAvailable.add(!availableWorkers.isEmpty());
        trimList(highPriorityWorkerAvailable);
      }
      if (getCurrentPoolSize() >= getMaxPoolSize()) {
        lastHighDelay=task.getDelayEstimateInMillis();
        w=getExistingWorker(Long.MAX_VALUE);
      }
 else {
        lastHighDelay=0;
        if (availableWorkers.isEmpty()) {
          w=makeNewWorker();
        }
 else {
          w=availableWorkers.removeFirst();
        }
      }
    }
  }
  if (w != null) {
    Clock.systemNanoTime();
    long executionDelay=task.getDelayEstimateInMillis();
    if (executionDelay <= 0) {
synchronized (highPriorityExecutionDelay.getModificationLock()) {
        highPriorityExecutionDelay.add(executionDelay * -1);
        trimList(highPriorityExecutionDelay);
      }
    }
    w.nextTask(task);
  }
}
Program: 161715
Project: 161715
Buggy source:
/** 
 * Stops task consumers, and clears all waiting tasks (low and high priority).
 * @return A list of Runnables that had been removed from the queues
 */
protected List<Runnable> clearTaskQueue(){
synchronized (highPriorityLock) {
synchronized (lowPriorityLock) {
      highPriorityConsumer.stopIfRunning();
      highPriorityConsumer.stopIfRunning();
      List<Runnable> removedTasks=new ArrayList<Runnable>(highPriorityQueue.size() + lowPriorityQueue.size());
synchronized (highPriorityQueue.getLock()) {
        Iterator<TaskWrapper> it=highPriorityQueue.iterator();
        while (it.hasNext()) {
          TaskWrapper tw=it.next();
          tw.cancel();
          if (!(tw.task instanceof ShutdownRunnable)) {
            removedTasks.add(tw.task);
          }
        }
        lowPriorityQueue.clear();
      }
synchronized (lowPriorityQueue.getLock()) {
        Iterator<TaskWrapper> it=lowPriorityQueue.iterator();
        while (it.hasNext()) {
          TaskWrapper tw=it.next();
          tw.cancel();
          removedTasks.add(tw.task);
        }
        lowPriorityQueue.clear();
      }
      return removedTasks;
    }
  }
}

Fixed version (ground truth):
/** 
 * Stops task consumers, and clears all waiting tasks (low and high priority).
 * @return A list of Runnables that had been removed from the queues
 */
protected List<Runnable> clearTaskQueue(){
synchronized (highPriorityLock) {
synchronized (lowPriorityLock) {
      highPriorityConsumer.stopIfRunning();
      highPriorityConsumer.stopIfRunning();
      List<Runnable> removedTasks=new ArrayList<Runnable>(highPriorityQueue.size() + lowPriorityQueue.size());
synchronized (highPriorityQueue.getLock()) {
        Iterator<TaskWrapper> it=highPriorityQueue.iterator();
        while (it.hasNext()) {
          TaskWrapper tw=it.next();
          tw.cancel();
          if (!(tw.task instanceof ShutdownRunnable)) {
            removedTasks.add(tw.task);
          }
        }
        highPriorityQueue.clear();
      }
synchronized (lowPriorityQueue.getLock()) {
        Iterator<TaskWrapper> it=lowPriorityQueue.iterator();
        while (it.hasNext()) {
          TaskWrapper tw=it.next();
          tw.cancel();
          removedTasks.add(tw.task);
        }
        lowPriorityQueue.clear();
      }
      return removedTasks;
    }
  }
}
Program: 161716
Project: 161716
Buggy source:
@Override public boolean get(){
  return scheduler.getCurrentPoolSize() == 0;
}

Fixed version (ground truth):
@Override public boolean get(){
  int queuedTaskQty=scheduler.lowPriorityQueue.size() + scheduler.highPriorityQueue.size();
  return queuedTaskQty == expectedRunnables.size();
}
Program: 161717
Project: 161717
Buggy source:
@Test public void shutdownNowTest(){
  PrioritySchedulerFactory factory=getPrioritySchedulerFactory();
  BlockingTestRunnable btr=new BlockingTestRunnable();
  try {
    PriorityScheduler scheduler=factory.makePriorityScheduler(1,1,1000);
    scheduler.execute(btr);
    List<TestRunnable> expectedRunnables=new ArrayList<TestRunnable>(TEST_QTY);
    for (int i=0; i < TEST_QTY; i++) {
      TestRunnable tr=new TestRunnable();
      if (i != 0) {
        expectedRunnables.add(tr);
      }
      scheduler.execute(tr);
    }
    btr.blockTillStarted();
    List<Runnable> canceledRunnables=scheduler.shutdownNow();
    btr.unblock();
    assertNotNull(canceledRunnables);
    assertTrue(canceledRunnables.containsAll(expectedRunnables));
    assertTrue(expectedRunnables.containsAll(canceledRunnables));
    Iterator<TestRunnable> it=expectedRunnables.iterator();
    while (it.hasNext()) {
      assertEquals(0,it.next().getRunCount());
    }
  }
  finally {
    btr.unblock();
    factory.shutdown();
  }
}

Fixed version (ground truth):
@Test public void shutdownNowTest(){
  PrioritySchedulerFactory factory=getPrioritySchedulerFactory();
  BlockingTestRunnable btr=new BlockingTestRunnable();
  try {
    final PriorityScheduler scheduler=factory.makePriorityScheduler(1,1,1000);
    scheduler.execute(btr);
    btr.blockTillStarted();
    final List<TestRunnable> expectedRunnables=new ArrayList<TestRunnable>(TEST_QTY);
    for (int i=0; i < TEST_QTY; i++) {
      TestRunnable tr=new TestRunnable();
      if (i > 1) {
        expectedRunnables.add(tr);
      }
      scheduler.execute(tr,i % 2 == 0 ? TaskPriority.High : TaskPriority.Low);
    }
    new TestCondition(){
      @Override public boolean get(){
        int queuedTaskQty=scheduler.lowPriorityQueue.size() + scheduler.highPriorityQueue.size();
        return queuedTaskQty == expectedRunnables.size();
      }
    }
.blockTillTrue();
    List<Runnable> canceledRunnables=scheduler.shutdownNow();
    btr.unblock();
    assertNotNull(canceledRunnables);
    assertTrue(canceledRunnables.containsAll(expectedRunnables));
    assertTrue(expectedRunnables.containsAll(canceledRunnables));
    Iterator<TestRunnable> it=expectedRunnables.iterator();
    while (it.hasNext()) {
      assertEquals(0,it.next().getRunCount());
    }
  }
  finally {
    btr.unblock();
    factory.shutdown();
  }
}
Program: 161718
Project: 161718
Buggy source:
@Test public void lastKnownTimeMillisTest(){
  long before=Clock.lastKnownTimeMillis();
  TestUtils.blockTillClockAdvances();
  long newTime;
  assertTrue((newTime=Clock.accurateTimeMillis()) > before);
  assertTrue(newTime <= Clock.lastKnownTimeMillis());
}

Fixed version (ground truth):
@Test public void lastKnownTimeMillisTest(){
  long before=Clock.lastKnownTimeMillis();
  TestUtils.blockTillClockAdvances();
  long newTime=-1;
  assertTrue((newTime=Clock.accurateTimeMillis()) > before);
  assertTrue(newTime <= Clock.lastKnownTimeMillis());
}
Program: 161719
Project: 161719
Buggy source:
@Override public <T>List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks,long timeout,TimeUnit unit) throws InterruptedException {
  long startTime=Clock.accurateTimeMillis();
  long timeoutInMs=unit.toMillis(timeout);
  List<Future<T>> resultList=new ArrayList<Future<T>>(tasks.size());
{
    Iterator<? extends Callable<T>> it=tasks.iterator();
    while (it.hasNext()) {
      Callable<T> c=it.next();
      if (c == null) {
        throw new NullPointerException();
      }
      ListenableRunnableFuture<T> fr=new ListenableFutureTask<T>(false,c);
      resultList.add(fr);
      scheduler.execute(fr);
    }
  }
{
    Iterator<Future<T>> it=resultList.iterator();
    long remainingTime=Math.max(0,timeoutInMs - (Clock.accurateTimeMillis() - startTime));
    while (it.hasNext() && remainingTime > 0) {
      try {
        it.next().get(remainingTime,TimeUnit.MILLISECONDS);
      }
 catch (      ExecutionException e) {
      }
catch (      TimeoutException e) {
        break;
      }
      remainingTime=Math.max(0,timeoutInMs - (Clock.accurateTimeMillis() - startTime));
    }
    while (it.hasNext()) {
      it.next().cancel(true);
    }
  }
  return resultList;
}

Fixed version (ground truth):
@Override public <T>List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks,long timeout,TimeUnit unit) throws InterruptedException {
  long startTime=Clock.accurateTimeMillis();
  long timeoutInMs=unit.toMillis(timeout);
  List<Future<T>> resultList=new ArrayList<Future<T>>(tasks.size());
{
    Iterator<? extends Callable<T>> it=tasks.iterator();
    while (it.hasNext()) {
      Callable<T> c=it.next();
      if (c == null) {
        throw new NullPointerException();
      }
      ListenableRunnableFuture<T> fr=new ListenableFutureTask<T>(false,c);
      resultList.add(fr);
      scheduler.execute(fr);
    }
  }
{
    Iterator<Future<T>> it=resultList.iterator();
    long remainingTime=timeoutInMs - (Clock.accurateTimeMillis() - startTime);
    while (it.hasNext() && remainingTime > 0) {
      Future<T> f=it.next();
      try {
        f.get(remainingTime,TimeUnit.MILLISECONDS);
      }
 catch (      ExecutionException e) {
      }
catch (      TimeoutException e) {
        f.cancel(true);
        break;
      }
      remainingTime=timeoutInMs - (Clock.accurateTimeMillis() - startTime);
    }
    while (it.hasNext()) {
      it.next().cancel(true);
    }
  }
  return resultList;
}
Program: 161721
Project: 161721
Buggy source:
/** 
 * Returns a count of how many tasks are either waiting to be executed,  or are scheduled to be executed at a future point for a specific priority.
 * @param priority priority for tasks to be counted
 * @return qty of tasks waiting execution or scheduled to be executed later
 */
public int getScheduledTaskCount(TaskPriority priority){
  if (priority == null) {
    return getScheduledTaskCount();
  }
switch (priority) {
case High:
    return highPriorityQueue.size();
case Low:
  return lowPriorityQueue.size();
default :
throw new UnsupportedOperationException();
}
}

Fixed version (ground truth):
/** 
 * Returns a count of how many tasks are either waiting to be executed,  or are scheduled to be executed at a future point for a specific priority.
 * @param priority priority for tasks to be counted
 * @return quantity of tasks waiting execution or scheduled to be executed later
 */
public int getScheduledTaskCount(TaskPriority priority){
  if (priority == null) {
    return getScheduledTaskCount();
  }
switch (priority) {
case High:
    return highPriorityQueue.size();
case Low:
  return lowPriorityQueue.size();
default :
throw new UnsupportedOperationException();
}
}
Program: 161722
Project: 161722
Buggy source:
/** 
 * Getter for the current qty of workers constructed (ether running or idle).
 * @return current worker count
 */
public int getCurrentPoolSize(){
synchronized (workersLock) {
    return currentPoolSize;
  }
}

Fixed version (ground truth):
/** 
 * Getter for the current quantity of workers constructed (either running or idle).
 * @return current worker count
 */
public int getCurrentPoolSize(){
synchronized (workersLock) {
    return currentPoolSize;
  }
}
Program: 161723
Project: 161723
Buggy source:
/** 
 * Stops any new tasks from being submitted to the pool.  But allows all tasks which are  submitted to execute, or scheduled (and have elapsed their delay time) to run.  If  recurring tasks are present they will also be unable to reschedule.  If shutdown or  shutdownNow has already been called, this will have no effect. If you wish to not want to run any queued tasks you should use {#link shutdownNow()).
 */
public void shutdown(){
  if (!shutdownStarted.getAndSet(true)) {
    addToHighPriorityQueue(new OneTimeTaskWrapper(new ShutdownRunnable(),TaskPriority.High,1));
  }
}

Fixed version (ground truth):
/** 
 * Stops any new tasks from being submitted to the pool.  But allows all tasks which are  submitted to execute, or scheduled (and have elapsed their delay time) to run.  If  recurring tasks are present they will also be unable to reschedule.  If shutdown or  shutdownNow has already been called, this will have no effect. If you wish to not want to run any queued tasks you should use shutdownNow().
 */
public void shutdown(){
  if (!shutdownStarted.getAndSet(true)) {
    addToHighPriorityQueue(new OneTimeTaskWrapper(new ShutdownRunnable(),TaskPriority.High,1));
  }
}
Program: 161724
Project: 161724
Buggy source:
/** 
 * Prestarts all core threads.  This will make new idle workers to accept future tasks.
 */
public void prestartAllCoreThreads(){
synchronized (workersLock) {
    boolean startedThreads=false;
    while (currentPoolSize <= corePoolSize) {
      availableWorkers.addFirst(makeNewWorker());
      startedThreads=true;
    }
    if (startedThreads) {
      workersLock.notifyAll();
    }
  }
}

Fixed version (ground truth):
/** 
 * Ensures all core threads have been started.  This will make new idle workers  to accept tasks.
 */
public void prestartAllCoreThreads(){
synchronized (workersLock) {
    boolean startedThreads=false;
    while (currentPoolSize <= corePoolSize) {
      availableWorkers.addFirst(makeNewWorker());
      startedThreads=true;
    }
    if (startedThreads) {
      workersLock.notifyAll();
    }
  }
}
Program: 161725
Project: 161725
Buggy source:
/** 
 * Call to get the total qty of high priority tasks this executor has handled.
 * @return total qty of high priority tasks run
 */
public int getHighPriorityTotalExecutionCount(){
  return totalHighPriorityExecutions.get();
}

Fixed version (ground truth):
/** 
 * Call to get the total quantity of high priority tasks this executor has handled.
 * @return total quantity of high priority tasks run
 */
public int getHighPriorityTotalExecutionCount(){
  return totalHighPriorityExecutions.get();
}
Program: 161726
Project: 161726
Buggy source:
/** 
 * Call to get the total qty of tasks this executor has handled.
 * @return total qty of tasks run
 */
public int getTotalExecutionCount(){
  return getHighPriorityTotalExecutionCount() + getLowPriorityTotalExecutionCount();
}

Fixed version (ground truth):
/** 
 * Call to get the total quantity of tasks this executor has handled.
 * @return total quantity of tasks run
 */
public int getTotalExecutionCount(){
  return getHighPriorityTotalExecutionCount() + getLowPriorityTotalExecutionCount();
}
Program: 161727
Project: 161727
Buggy source:
/** 
 * Call to return the number of callables and/or runnables which have been running longer  than the provided amount of time in milliseconds.
 * @param timeInMs threshold of time to search for execution
 * @return total qty of runnables and callables which have or are running longer than the provided time length
 */
public int getQtyRunningOverTime(long timeInMs){
  int result=0;
  long now=Clock.accurateTimeMillis();
  Iterator<Long> it=runningTasks.values().iterator();
  while (it.hasNext()) {
    Long startTime=it.next();
    if (now - startTime >= timeInMs) {
      result++;
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Call to return the number of callables and/or runnables which have been running longer  than the provided amount of time in milliseconds.
 * @param timeInMs threshold of time to search for execution
 * @return total quantity of runnables and callables which have or are running longer than the provided time length
 */
public int getQtyRunningOverTime(long timeInMs){
  int result=0;
  long now=Clock.accurateTimeMillis();
  Iterator<Long> it=runningTasks.values().iterator();
  while (it.hasNext()) {
    Long startTime=it.next();
    if (now - startTime >= timeInMs) {
      result++;
    }
  }
  return result;
}
Program: 161728
Project: 161728
Buggy source:
/** 
 * Call to get the total qty of low priority tasks this executor has handled.
 * @return total qty of low priority tasks run
 */
public int getLowPriorityTotalExecutionCount(){
  return totalLowPriorityExecutions.get();
}

Fixed version (ground truth):
/** 
 * Call to get the total quantity of low priority tasks this executor has handled.
 * @return total quantity of low priority tasks run
 */
public int getLowPriorityTotalExecutionCount(){
  return totalLowPriorityExecutions.get();
}
Program: 161729
Project: 161729
Buggy source:
@Override public Thread newThread(Runnable runnable){
  Thread thread=defaultFactory.newThread(runnable);
  thread.setDaemon(daemonThread);
  thread.setName("String_Node_Str" + NEXT_THREAD_ID.getAndIncrement());
  return thread;
}

Fixed version (ground truth):
@Override public Thread newThread(Runnable runnable){
  Thread thread=defaultFactory.newThread(runnable);
  thread.setDaemon(daemonThread);
  thread.setName(SingleThreadScheduler.class.getSimpleName() + "String_Node_Str" + NEXT_THREAD_ID.getAndIncrement());
  return thread;
}
Program: 161730
Project: 161730
Buggy source:
/** 
 * Call to check how many tasks have been queued up for a given key.  Depending on  what constructor was used, and if a true was passed in for "accurateQueueSize", the  accuracy of this call varies dramatically. If true was not supplied in the constructor for "accurateQueueSize", this will only  report how many tasks have not been accepted by the worker yet.  The accepting of those  tasks occur in batches, so this number will varry dramatically (and probably be unusable). So it is highly recommended that if your interested in this functionality you supply a  true into the constructor. Supplying a true for "accurateQueueSize" in the constructor does involve some performance  cost, but that overhead should be minimal (just no reason to accept any loss if not  interested in this feature).
 * @since 1.2.0
 * @param threadKey key for task queue to examine
 * @return the number of tasks queued for the key
 */
public int getTaskQueueSize(Object threadKey){
  TaskQueueWorker worker=taskWorkers.get(threadKey);
  if (worker == null) {
    return 0;
  }
 else {
    return worker.getQueueSize();
  }
}

Fixed version (ground truth):
/** 
 * Call to check how many tasks have been queued up for a given key.  Depending on  what constructor was used, and if a true was passed in for "accurateQueueSize", the  accuracy of this call varies dramatically. If true was not supplied in the constructor for "accurateQueueSize", this will only  report how many tasks have not been accepted by the worker yet.  The accepting of those  tasks occur in batches, so this number will vary dramatically (and probably be unusable). So it is highly recommended that if your interested in this functionality you supply a  true into the constructor. Supplying a true for "accurateQueueSize" in the constructor does involve some performance  cost, but that overhead should be minimal (just no reason to accept any loss if not  interested in this feature).
 * @since 1.2.0
 * @param threadKey key for task queue to examine
 * @return the number of tasks queued for the key
 */
public int getTaskQueueSize(Object threadKey){
  TaskQueueWorker worker=taskWorkers.get(threadKey);
  if (worker == null) {
    return 0;
  }
 else {
    return worker.getQueueSize();
  }
}
Program: 161731
Project: 161731
Buggy source:
@Override public String toString(){
  return "String_Node_Str" + queue.toString();
}

Fixed version (ground truth):
@Override public String toString(){
  return queue.toString();
}
Program: 161732
Project: 161732
Buggy source:
/** 
 * This call is similar to makeCompleteFuture in that it will immediately provide a  future that can not be canceled, and will not be satifised till all provided  futures complete.   This future provides a list of the completed futures as the result.  The order  of this list is NOT deterministic.
 * @since 1.2.0
 * @param < T > type of result returned from the futures
 * @param futures Structure of futures to iterate over
 * @return ListenableFuture which will be done once all futures provided are done
 */
public static <T>ListenableFuture<List<ListenableFuture<? extends T>>> makeCompleteListFuture(Iterable<? extends ListenableFuture<? extends T>> futures){
  return new AllFutureCollection<T>(futures);
}

Fixed version (ground truth):
/** 
 * This call is similar to makeCompleteFuture in that it will immediately provide a  future that can not be canceled, and will not be satisfied till all provided  futures complete.   This future provides a list of the completed futures as the result.  The order  of this list is NOT deterministic.
 * @since 1.2.0
 * @param < T > type of result returned from the futures
 * @param futures Structure of futures to iterate over
 * @return ListenableFuture which will be done once all futures provided are done
 */
public static <T>ListenableFuture<List<ListenableFuture<? extends T>>> makeCompleteListFuture(Iterable<? extends ListenableFuture<? extends T>> futures){
  return new AllFutureCollection<T>(futures);
}
Program: 161733
Project: 161733
Buggy source:
/** 
 * This call is similar to makeCompleteFuture in that it will immediately provide a  future that can not be canceled, and will not be satifised till all provided  futures complete.   This future provides a list of the futures that completed without throwing  an exception nor were canceled.  The order of the resulting list is NOT  deterministic.
 * @since 1.2.0
 * @param < T > type of result returned from the futures
 * @param futures Structure of futures to iterate over
 * @return ListenableFuture which will be done once all futures provided are done
 */
public static <T>ListenableFuture<List<ListenableFuture<? extends T>>> makeSuccessListFuture(Iterable<? extends ListenableFuture<? extends T>> futures){
  return new SuccessFutureCollection<T>(futures);
}

Fixed version (ground truth):
/** 
 * This call is similar to makeCompleteFuture in that it will immediately provide a  future that can not be canceled, and will not be satisfied till all provided  futures complete.   This future provides a list of the futures that completed without throwing  an exception nor were canceled.  The order of the resulting list is NOT  deterministic.
 * @since 1.2.0
 * @param < T > type of result returned from the futures
 * @param futures Structure of futures to iterate over
 * @return ListenableFuture which will be done once all futures provided are done
 */
public static <T>ListenableFuture<List<ListenableFuture<? extends T>>> makeSuccessListFuture(Iterable<? extends ListenableFuture<? extends T>> futures){
  return new SuccessFutureCollection<T>(futures);
}
Program: 161734
Project: 161734
Buggy source:
/** 
 * This call is similar to makeCompleteFuture in that it will immediately provide a  future that can not be canceled, and will not be satifised till all provided  futures complete.   This future provides a list of the futures that failed by either throwing an  exception or were canceled.  The order of the resulting list is NOT  deterministic.
 * @since 1.2.0
 * @param < T > type of result returned from the futures
 * @param futures Structure of futures to iterate over
 * @return ListenableFuture which will be done once all futures provided are done
 */
public static <T>ListenableFuture<List<ListenableFuture<? extends T>>> makeFailureListFuture(Iterable<? extends ListenableFuture<? extends T>> futures){
  return new FailureFutureCollection<T>(futures);
}

Fixed version (ground truth):
/** 
 * This call is similar to makeCompleteFuture in that it will immediately provide a  future that can not be canceled, and will not be satisfied till all provided  futures complete.   This future provides a list of the futures that failed by either throwing an  exception or were canceled.  The order of the resulting list is NOT  deterministic.
 * @since 1.2.0
 * @param < T > type of result returned from the futures
 * @param futures Structure of futures to iterate over
 * @return ListenableFuture which will be done once all futures provided are done
 */
public static <T>ListenableFuture<List<ListenableFuture<? extends T>>> makeFailureListFuture(Iterable<? extends ListenableFuture<? extends T>> futures){
  return new FailureFutureCollection<T>(futures);
}
Program: 161735
Project: 161735
Buggy source:
/** 
 * Construct a new execution limiter that implements the   {@link Executor} interface.
 * @param executor {@link Executor} to submit task executions to.
 * @param maxConcurrency maximum qty of runnables to run in parallel
 * @param subPoolName name to describe threads while tasks running in pool (null to not change thread names)
 */
public ExecutorLimiter(Executor executor,int maxConcurrency,String subPoolName){
  super(maxConcurrency,subPoolName);
  if (executor == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.executor=executor;
  waitingTasks=new ConcurrentLinkedQueue<LimiterRunnableWrapper>();
}

Fixed version (ground truth):
/** 
 * Construct a new execution limiter that implements the   {@link Executor} interface.
 * @param executor {@link Executor} to submit task executions to.
 * @param maxConcurrency maximum quantity of runnables to run in parallel
 * @param subPoolName name to describe threads while tasks running in pool (null to not change thread names)
 */
public ExecutorLimiter(Executor executor,int maxConcurrency,String subPoolName){
  super(maxConcurrency,subPoolName);
  if (executor == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.executor=executor;
  waitingTasks=new ConcurrentLinkedQueue<LimiterRunnableWrapper>();
}
Program: 161736
Project: 161736
Buggy source:
/** 
 * Constructs a new limiter that implements the   {@link PrioritySchedulerInterface}.
 * @param scheduler {@link PrioritySchedulerInterface} implementation to submit task executions to.
 * @param maxConcurrency maximum qty of runnables to run in parallel
 * @param subPoolName name to describe threads while tasks running in pool (null to not change thread names)
 */
public PrioritySchedulerLimiter(PrioritySchedulerInterface scheduler,int maxConcurrency,String subPoolName){
  super(scheduler,maxConcurrency,subPoolName);
  this.scheduler=scheduler;
}

Fixed version (ground truth):
/** 
 * Constructs a new limiter that implements the   {@link PrioritySchedulerInterface}.
 * @param scheduler {@link PrioritySchedulerInterface} implementation to submit task executions to.
 * @param maxConcurrency maximum quantity of runnables to run in parallel
 * @param subPoolName name to describe threads while tasks running in pool (null to not change thread names)
 */
public PrioritySchedulerLimiter(PrioritySchedulerInterface scheduler,int maxConcurrency,String subPoolName){
  super(scheduler,maxConcurrency,subPoolName);
  this.scheduler=scheduler;
}
Program: 161737
Project: 161737
Buggy source:
/** 
 * Constructs a new limiter that implements the   {@link SchedulerServiceInterface}.
 * @param scheduler {@link SchedulerServiceInterface} implementation to submit task executions to.
 * @param maxConcurrency maximum qty of runnables to run in parallel
 * @param subPoolName name to describe threads while tasks running in pool (null to not change thread names)
 */
public SchedulerServiceLimiter(SchedulerServiceInterface scheduler,int maxConcurrency,String subPoolName){
  super(scheduler,maxConcurrency,subPoolName);
  this.scheduler=scheduler;
}

Fixed version (ground truth):
/** 
 * Constructs a new limiter that implements the   {@link SchedulerServiceInterface}.
 * @param scheduler {@link SchedulerServiceInterface} implementation to submit task executions to.
 * @param maxConcurrency maximum quantity of runnables to run in parallel
 * @param subPoolName name to describe threads while tasks running in pool (null to not change thread names)
 */
public SchedulerServiceLimiter(SchedulerServiceInterface scheduler,int maxConcurrency,String subPoolName){
  super(scheduler,maxConcurrency,subPoolName);
  this.scheduler=scheduler;
}
Program: 161738
Project: 161738
Buggy source:
@Override public void scheduleWithFixedDelay(Runnable task,long initialDelay,long recurringDelay){
  if (task == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
 else   if (initialDelay < 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
 else   if (recurringDelay < 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  scheduler.scheduleWithFixedDelay(new ThrowableSurpressingRunnable(task),initialDelay,recurringDelay,TimeUnit.MILLISECONDS);
}

Fixed version (ground truth):
@Override public void scheduleWithFixedDelay(Runnable task,long initialDelay,long recurringDelay){
  if (task == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
 else   if (initialDelay < 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
 else   if (recurringDelay < 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  scheduler.scheduleWithFixedDelay(new ThrowableSuppressingRunnable(task),initialDelay,recurringDelay,TimeUnit.MILLISECONDS);
}
Program: 161739
Project: 161739
Buggy source:
/** 
 * Constructs a new ThrowableSurpressingRunnable with the provided task.   If the task is null, when this is run no operation will occur.
 * @param task task to be executed and have exceptions prevented from being thrown
 */
public ThrowableSurpressingRunnable(Runnable task){
  this.task=task;
}

Fixed version (ground truth):
/** 
 * Constructs a new ThrowableSurpressingRunnable with the provided task.   If the task is null, when this is run no operation will occur.
 * @param task task to be executed and have exceptions prevented from being thrown
 */
public ThrowableSurpressingRunnable(Runnable task){
  super(task);
}
Program: 161741
Project: 161741
Buggy source:
@Test public void resetTest(){
  profiler.start();
  blockForProfilerSample();
  profiler.stop();
  profiler.reset();
  assertEquals(0,profiler.threadTraces.size());
  assertEquals(0,profiler.getCollectedSampleQty());
}

Fixed version (ground truth):
@Test public void resetTest(){
  profiler.start();
  blockForProfilerSample();
  final Thread runningThread=profiler.collectorThread.get();
  profiler.stop();
  new TestCondition(){
    @Override public boolean get(){
      return !runningThread.isAlive();
    }
  }
.blockTillTrue();
  profiler.reset();
  assertEquals(0,profiler.threadTraces.size());
  assertEquals(0,profiler.getCollectedSampleQty());
}
Program: 161742
Project: 161742
Buggy source:
@Override public boolean get(){
  return profiler.getCollectedSampleQty() > 0;
}

Fixed version (ground truth):
@Override public boolean get(){
  return !runningThread.isAlive();
}
Program: 161743
Project: 161743
Buggy source:
/** 
 * Checks if there are tasks ready to be run on the scheduler.  If this returns  true, the next .tick() call is guaranteed to run at least one task.
 * @return true if there are task waiting to run.
 */
public boolean hasTaskReadyToRun(){
  return getNextReadyTask() != null;
}

Fixed version (ground truth):
/** 
 * Checks if there are tasks ready to be run on the scheduler.  Generally this is called from  the same thread that would call .tick() (but does not have to be).  If .tick() is not  currently being called, this call indicates if the next .tick() will have at least one task  to run.  If .tick() is currently running, this call will indicate if there is at least one  more task to run (not including the task which may currently be running).
 * @return true if there are task waiting to run.
 */
public boolean hasTaskReadyToRun(){
synchronized (taskQueue.getModificationLock()) {
    TaskContainer nextTask=getNextReadyTask();
    if (nextTask == null) {
      return false;
    }
 else     if (nextTask.running && taskQueue.size() == 1) {
      return false;
    }
 else {
      return true;
    }
  }
}
Program: 161744
Project: 161744
Buggy source:
@Override public void prepareForRun(){
synchronized (taskQueue.getModificationLock()) {
    startInsertion();
    try {
      int insertionIndex=ListUtils.getInsertionEndIndex(taskQueue,recurringDelay,true);
      taskQueue.reposition(this,insertionIndex,false);
      nextRunTime=nowInMillis() + recurringDelay;
    }
  finally {
      endInsertion();
    }
  }
}

Fixed version (ground truth):
@Override public void prepareForRun(){
}
Program: 161745
Project: 161745
Buggy source:
protected TaskContainer(Runnable runnable){
  this.runnable=runnable;
}

Fixed version (ground truth):
protected TaskContainer(Runnable runnable){
  this.runnable=runnable;
  this.running=false;
}
Program: 161746
Project: 161746
Buggy source:
protected void runTask(){
  prepareForRun();
  runnable.run();
}

Fixed version (ground truth):
protected void runTask(){
  running=true;
  prepareForRun();
  try {
    runnable.run();
  }
  finally {
    runComplete();
    running=false;
  }
}
Program: 161747
Project: 161747
Buggy source:
protected TestContainer(int delay){
  scheduler.super(new TestRunnable());
  this.delay=delay;
}

Fixed version (ground truth):
protected TestContainer(int delay,boolean throwException){
  scheduler.super(throwException ? new TestRuntimeFailureRunnable() : new TestRunnable());
  this.delay=delay;
}
Program: 161748
Project: 161748
Buggy source:
@Test public void compareToTest(){
  TestContainer tc0=new TestContainer(0);
  assertEquals(0,tc0.compareTo(tc0));
  assertEquals(0,tc0.compareTo(new TestContainer(0)));
  assertTrue(tc0.compareTo(new TestContainer(1)) < 0);
  assertTrue(tc0.compareTo(new TestContainer(-1)) > 0);
  Random r=new Random(Clock.lastKnownTimeMillis());
  List<TestContainer> testList=new ArrayList<TestContainer>(TEST_QTY);
  for (int i=0; i < TEST_QTY; i++) {
    testList.add(new TestContainer(r.nextInt(100)));
  }
  Collections.sort(testList);
  int lastDelay=Integer.MIN_VALUE;
  Iterator<TestContainer> it=testList.iterator();
  while (it.hasNext()) {
    assertTrue(lastDelay <= (lastDelay=it.next().delay));
  }
}

Fixed version (ground truth):
@Test public void compareToTest(){
  TestContainer tc0=new TestContainer(0,false);
  assertEquals(0,tc0.compareTo(tc0));
  assertEquals(0,tc0.compareTo(new TestContainer(0,false)));
  assertTrue(tc0.compareTo(new TestContainer(1,false)) < 0);
  assertTrue(tc0.compareTo(new TestContainer(-1,false)) > 0);
  Random r=new Random(Clock.lastKnownTimeMillis());
  List<TestContainer> testList=new ArrayList<TestContainer>(TEST_QTY);
  for (int i=0; i < TEST_QTY; i++) {
    testList.add(new TestContainer(r.nextInt(100),false));
  }
  Collections.sort(testList);
  int lastDelay=Integer.MIN_VALUE;
  Iterator<TestContainer> it=testList.iterator();
  while (it.hasNext()) {
    assertTrue(lastDelay <= (lastDelay=it.next().delay));
  }
}
Program: 161749
Project: 161749
Buggy source:
@Test public void getContainedRunnableTest(){
  TestContainer tc=new TestContainer(0);
  assertTrue(tc.getContainedRunnable() == tc.runnable);
}

Fixed version (ground truth):
@Test public void getContainedRunnableTest(){
  TestContainer tc=new TestContainer(0,false);
  assertTrue(tc.getContainedRunnable() == tc.runnable);
}
Program: 161750
Project: 161750
Buggy source:
protected void runLowPriorityTask(TaskWrapper task) throws InterruptedException {
  Worker w=null;
synchronized (workersLock) {
    if (!shutdownFinishing) {
      long waitAmount;
      while (currentPoolSize >= maxPoolSize && availableWorkers.size() < WORKER_CONTENTION_LEVEL && !shutdownFinishing && (waitAmount=task.getDelayEstimateInMillis() - lastHighDelay) > LOW_PRIORITY_WAIT_TOLLERANCE_IN_MS) {
        if (highPriorityQueue.isEmpty()) {
          lastHighDelay=0;
        }
 else {
          workersLock.wait(waitAmount);
          Clock.accurateTime();
        }
      }
      if (!shutdownFinishing) {
        long waitTime;
        if (currentPoolSize >= maxPoolSize) {
          waitTime=Long.MAX_VALUE;
        }
 else {
          waitTime=maxWaitForLowPriorityInMs;
        }
        w=getExistingWorker(waitTime);
        if (w == null) {
          if (currentPoolSize >= maxPoolSize) {
            w=getExistingWorker(Long.MAX_VALUE);
          }
 else {
            w=makeNewWorker();
          }
        }
      }
    }
  }
  if (w != null) {
    w.nextTask(task);
  }
}

Fixed version (ground truth):
protected void runLowPriorityTask(TaskWrapper task) throws InterruptedException {
  Worker w=null;
synchronized (workersLock) {
    if (!shutdownFinishing) {
      long waitAmount;
      while (currentPoolSize >= maxPoolSize && availableWorkers.size() < WORKER_CONTENTION_LEVEL && !shutdownFinishing && !highPriorityQueue.isEmpty() && (waitAmount=task.getDelayEstimateInMillis() - lastHighDelay) > LOW_PRIORITY_WAIT_TOLLERANCE_IN_MS) {
        workersLock.wait(waitAmount);
        Clock.accurateTime();
      }
      if (highPriorityQueue.isEmpty()) {
        lastHighDelay=0;
      }
      if (!shutdownFinishing) {
        long waitTime;
        if (currentPoolSize >= maxPoolSize) {
          waitTime=Long.MAX_VALUE;
        }
 else {
          waitTime=maxWaitForLowPriorityInMs;
        }
        w=getExistingWorker(waitTime);
        if (w == null) {
          if (currentPoolSize >= maxPoolSize) {
            w=getExistingWorker(Long.MAX_VALUE);
          }
 else {
            w=makeNewWorker();
          }
        }
      }
    }
  }
  if (w != null) {
    w.nextTask(task);
  }
}
Program: 161751
Project: 161751
Buggy source:
protected void addToQueue(TaskWrapper task){
  verifyNotShutdown();
switch (task.priority) {
case High:
    addToHighPriorityQueue(task);
  break;
case Low:
addToLowPriorityQueue(task);
break;
default :
throw new UnsupportedOperationException("String_Node_Str" + task.priority);
}
}

Fixed version (ground truth):
protected void addToQueue(TaskWrapper task){
  if (shutdownStarted.get()) {
    throw new IllegalStateException("String_Node_Str");
  }
switch (task.priority) {
case High:
    addToHighPriorityQueue(task);
  break;
case Low:
addToLowPriorityQueue(task);
break;
default :
throw new UnsupportedOperationException("String_Node_Str" + task.priority);
}
}
Program: 161752
Project: 161752
Buggy source:
protected void shutdownAllWorkers(){
synchronized (workersLock) {
    Iterator<Worker> it=availableWorkers.iterator();
    while (it.hasNext()) {
      Worker w=it.next();
      it.remove();
      killWorker(w);
    }
  }
}

Fixed version (ground truth):
protected void shutdownAllWorkers(){
synchronized (workersLock) {
    Iterator<Worker> it=availableWorkers.iterator();
    while (it.hasNext()) {
      Worker w=it.next();
      it.remove();
      killWorker(w);
    }
    workersLock.notifyAll();
  }
}
Program: 161753
Project: 161753
Buggy source:
@Override protected void runHighPriorityTask(TaskWrapper task) throws InterruptedException {
  Worker w=null;
synchronized (workersLock) {
    if (!isShutdown()) {
synchronized (highPriorityWorkerAvailable.getModificationLock()) {
        highPriorityWorkerAvailable.add(!availableWorkers.isEmpty());
        trimList(highPriorityWorkerAvailable);
      }
      if (getCurrentPoolSize() >= getMaxPoolSize()) {
        w=getExistingWorker(Long.MAX_VALUE);
      }
 else {
        if (availableWorkers.isEmpty()) {
          w=makeNewWorker();
        }
 else {
          w=availableWorkers.removeFirst();
        }
      }
    }
  }
  if (w != null) {
    Clock.accurateTime();
    long executionDelay=task.getDelayEstimateInMillis();
    if (executionDelay <= 0) {
synchronized (highPriorityExecutionDelay.getModificationLock()) {
        highPriorityExecutionDelay.add(executionDelay * -1);
        trimList(highPriorityExecutionDelay);
      }
    }
    w.nextTask(task);
  }
}

Fixed version (ground truth):
@Override protected void runHighPriorityTask(TaskWrapper task) throws InterruptedException {
  Worker w=null;
synchronized (workersLock) {
    if (!getShutdownFinishing()) {
synchronized (highPriorityWorkerAvailable.getModificationLock()) {
        highPriorityWorkerAvailable.add(!availableWorkers.isEmpty());
        trimList(highPriorityWorkerAvailable);
      }
      if (getCurrentPoolSize() >= getMaxPoolSize()) {
        w=getExistingWorker(Long.MAX_VALUE);
      }
 else {
        lastHighDelay=0;
        if (availableWorkers.isEmpty()) {
          w=makeNewWorker();
        }
 else {
          w=availableWorkers.removeFirst();
        }
      }
    }
  }
  if (w != null) {
    Clock.accurateTime();
    long executionDelay=task.getDelayEstimateInMillis();
    if (executionDelay <= 0) {
synchronized (highPriorityExecutionDelay.getModificationLock()) {
        highPriorityExecutionDelay.add(executionDelay * -1);
        trimList(highPriorityExecutionDelay);
      }
    }
    w.nextTask(task);
  }
}
Program: 161754
Project: 161754
Buggy source:
@Override protected void runLowPriorityTask(TaskWrapper task) throws InterruptedException {
  Worker w=null;
synchronized (workersLock) {
    if (!isShutdown()) {
      if (getCurrentPoolSize() >= getMaxPoolSize()) {
synchronized (lowPriorityWorkerAvailable.getModificationLock()) {
          lowPriorityWorkerAvailable.add(!availableWorkers.isEmpty());
          trimList(lowPriorityWorkerAvailable);
        }
        w=getExistingWorker(Long.MAX_VALUE);
      }
 else {
        w=getExistingWorker(getMaxWaitForLowPriority());
synchronized (lowPriorityWorkerAvailable.getModificationLock()) {
          lowPriorityWorkerAvailable.add(w != null);
          trimList(lowPriorityWorkerAvailable);
        }
      }
      if (w == null) {
        if (getCurrentPoolSize() >= getMaxPoolSize()) {
          w=getExistingWorker(Long.MAX_VALUE);
        }
 else {
          w=makeNewWorker();
        }
      }
    }
  }
  if (w != null) {
    Clock.accurateTime();
    long executionDelay=task.getDelayEstimateInMillis();
    if (executionDelay <= 0) {
synchronized (lowPriorityExecutionDelay.getModificationLock()) {
        lowPriorityExecutionDelay.add(executionDelay * -1);
        trimList(lowPriorityExecutionDelay);
      }
    }
    w.nextTask(task);
  }
}

Fixed version (ground truth):
@Override protected void runLowPriorityTask(TaskWrapper task) throws InterruptedException {
  Worker w=null;
synchronized (workersLock) {
    if (!getShutdownFinishing()) {
      long waitAmount;
      while (getCurrentPoolSize() >= getMaxPoolSize() && availableWorkers.size() < WORKER_CONTENTION_LEVEL && !getShutdownFinishing() && !highPriorityQueue.isEmpty() && (waitAmount=task.getDelayEstimateInMillis() - lastHighDelay) > LOW_PRIORITY_WAIT_TOLLERANCE_IN_MS) {
        workersLock.wait(waitAmount);
        Clock.accurateTime();
      }
      if (highPriorityQueue.isEmpty()) {
        lastHighDelay=0;
      }
      if (!getShutdownFinishing()) {
        if (getCurrentPoolSize() >= getMaxPoolSize()) {
synchronized (lowPriorityWorkerAvailable.getModificationLock()) {
            lowPriorityWorkerAvailable.add(!availableWorkers.isEmpty());
            trimList(lowPriorityWorkerAvailable);
          }
          w=getExistingWorker(Long.MAX_VALUE);
        }
 else {
          w=getExistingWorker(getMaxWaitForLowPriority());
synchronized (lowPriorityWorkerAvailable.getModificationLock()) {
            lowPriorityWorkerAvailable.add(w != null);
            trimList(lowPriorityWorkerAvailable);
          }
        }
        if (w == null) {
          if (getCurrentPoolSize() >= getMaxPoolSize()) {
            w=getExistingWorker(Long.MAX_VALUE);
          }
 else {
            w=makeNewWorker();
          }
        }
      }
    }
  }
  if (w != null) {
    Clock.accurateTime();
    long executionDelay=task.getDelayEstimateInMillis();
    if (executionDelay <= 0) {
synchronized (lowPriorityExecutionDelay.getModificationLock()) {
        lowPriorityExecutionDelay.add(executionDelay * -1);
        trimList(lowPriorityExecutionDelay);
      }
    }
    w.nextTask(task);
  }
}
Program: 161755
Project: 161755
Buggy source:
@Override public void handleRunFinish(){
  if (!added) {
    distributor.addTask(threadTracker,this);
    added=true;
  }
}

Fixed version (ground truth):
@Override public void handleRunFinish(){
  throw testException;
}
Program: 161756
Project: 161756
Buggy source:
@Test public void handleExceptionWithUncaughtExceptionHandler(){
  PrintStream originalSystemErr=System.err;
  try {
    final StringBuilder sb=new StringBuilder();
    System.setErr(new PrintStream(new OutputStream(){
      @Override public void write(      int b) throws IOException {
        sb.append((char)b);
      }
    }
));
    TestUncaughtExceptionHandler ueh=new TestUncaughtExceptionHandler();
    Thread.setDefaultUncaughtExceptionHandler(ueh);
    Exception e=new Exception();
    ExceptionUtils.handleException(e);
    assertEquals(sb.length(),0);
    assertEquals(ueh.callCount,1);
    assertTrue(ueh.calledWithThread == Thread.currentThread());
    assertTrue(ueh.providedThrowable == e);
  }
  finally {
    System.setErr(originalSystemErr);
  }
}

Fixed version (ground truth):
@Test public void handleExceptionWithUncaughtExceptionHandler(){
  PrintStream originalSystemErr=System.err;
  try {
    final StringBuilder sb=new StringBuilder();
    System.setErr(new PrintStream(new OutputStream(){
      @Override public void write(      int b) throws IOException {
        sb.append((char)b);
      }
    }
));
    TestUncaughtExceptionHandler ueh=new TestUncaughtExceptionHandler();
    Thread.setDefaultUncaughtExceptionHandler(ueh);
    Exception e=new Exception();
    ExceptionUtils.handleException(e);
    assertEquals(sb.length(),0);
    assertEquals(ueh.getCallCount(),1);
    assertTrue(ueh.getCalledWithThread() == Thread.currentThread());
    assertTrue(ueh.getCalledWithThrowable() == e);
  }
  finally {
    System.setErr(originalSystemErr);
  }
}
Program: 161757
Project: 161757
Buggy source:
@Override public boolean isDone(){
synchronized (lock) {
    return done;
  }
}

Fixed version (ground truth):
@Override public boolean isDone(){
synchronized (lock) {
    return done || canceled;
  }
}
Program: 161758
Project: 161758
Buggy source:
@Override public void addListener(Runnable listener,Executor executor){
synchronized (lock) {
    if (done || canceled) {
      runListener(listener,executor,true);
    }
 else {
      listeners.put(listener,executor);
    }
  }
}

Fixed version (ground truth):
@Override public void addListener(Runnable listener,Executor executor){
synchronized (lock) {
    if (isDone()) {
      runListener(listener,executor,true);
    }
 else {
      listeners.put(listener,executor);
    }
  }
}
Program: 161759
Project: 161759
Buggy source:
@Override public void run(){
  while (true) {
    List<Runnable> nextList;
synchronized (agentLock) {
      nextList=queue;
      if (nextList.isEmpty()) {
        taskWorkers.remove(mapKey);
        break;
      }
 else {
        queue=new LinkedList<Runnable>();
      }
    }
    Iterator<Runnable> it=nextList.iterator();
    while (it.hasNext()) {
      try {
        Runnable next=it.next();
        if (factory != null && next instanceof VirtualRunnable) {
          ((VirtualRunnable)next).run(factory);
        }
 else {
          next.run();
        }
      }
 catch (      Throwable t) {
        UncaughtExceptionHandler ueh=Thread.getDefaultUncaughtExceptionHandler();
        ueh.uncaughtException(Thread.currentThread(),t);
      }
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  while (true) {
    List<Runnable> nextList;
synchronized (agentLock) {
      nextList=queue;
      if (nextList.isEmpty()) {
        taskWorkers.remove(mapKey);
        break;
      }
 else {
        queue=new LinkedList<Runnable>();
      }
    }
    Iterator<Runnable> it=nextList.iterator();
    while (it.hasNext()) {
      try {
        Runnable next=it.next();
        if (factory != null && next instanceof VirtualRunnable) {
          ((VirtualRunnable)next).run(factory);
        }
 else {
          next.run();
        }
      }
 catch (      Throwable t) {
        UncaughtExceptionHandler ueh=Thread.getDefaultUncaughtExceptionHandler();
        if (ueh != null) {
          ueh.uncaughtException(Thread.currentThread(),t);
        }
 else {
          t.printStackTrace();
        }
      }
    }
  }
}