nus-yam/ex-repair huggingface dataset:
Program: 161760
Project: 161760
Buggy source:
protected void trackTaskStart(Wrapper taskWrapper){
  runningTasks.put(taskWrapper,Clock.accurateTime());
switch (taskWrapper.priority) {
case High:
    totalHighPriorityExecutions.incrementAndGet();
  break;
case Low:
totalLowPriorityExecutions.incrementAndGet();
break;
default :
throw new UnsupportedOperationException("String_Node_Str" + taskWrapper.priority);
}
}

Fixed version (ground truth):
protected synchronized void trackTaskStart(Wrapper taskWrapper){
  runningTasks.put(taskWrapper,Clock.accurateTime());
switch (taskWrapper.priority) {
case High:
    totalHighPriorityExecutions.incrementAndGet();
  break;
case Low:
totalLowPriorityExecutions.incrementAndGet();
break;
default :
throw new UnsupportedOperationException("String_Node_Str" + taskWrapper.priority);
}
}
Program: 161761
Project: 161761
Buggy source:
/** 
 * Call to see how frequently high priority tasks are able to run without creating  a new thread. Returns -1 if no statistics for high priority tasks have been recorded yet.
 * @return percent that an existing worker could be used on high priority tasks
 */
public double getHighPriorityThreadReusePercent(){
  return getTruePercent(highPriorityWorkerAvailable);
}

Fixed version (ground truth):
/** 
 * Call to see how frequently high priority tasks are able to run without creating  a new thread. Returns -1 if no statistics for high priority tasks have been recorded yet.
 * @return percent of time that threads are able to be reused for high priority tasks
 */
public double getHighPriorityThreadReusePercent(){
  return getTruePercent(highPriorityWorkerAvailable);
}
Program: 161762
Project: 161762
Buggy source:
/** 
 * Call to see how frequently low priority tasks are able to run without creating  a new thread. Returns -1 if no statistics for high priority tasks have been recorded yet.
 * @return percent that an existing worker could be used on low priority tasks
 */
public double getLowPriorityThreadReusePercent(){
  return getTruePercent(lowPriorityWorkerAvailable);
}

Fixed version (ground truth):
/** 
 * Call to see how frequently low priority tasks are able to run without creating  a new thread. Returns -1 if no statistics for high priority tasks have been recorded yet.
 * @return percent of time that threads are able to be reused for low priority tasks
 */
public double getLowPriorityThreadReusePercent(){
  return getTruePercent(lowPriorityWorkerAvailable);
}
Program: 161763
Project: 161763
Buggy source:
@Override public long getDelay(TimeUnit unit){
  if (executing) {
    return Long.MAX_VALUE;
  }
 else {
    return TimeUnit.MILLISECONDS.convert(nextRunTime - ClockWrapper.getAccurateTime(),unit);
  }
}

Fixed version (ground truth):
@Override public long getDelay(TimeUnit unit){
  if (executing) {
    return Long.MAX_VALUE;
  }
 else {
    return TimeUnit.MILLISECONDS.convert(getNextDelayInMillis(),unit);
  }
}
Program: 161764
Project: 161764
Buggy source:
private void reschedule(){
  nextRunTime=ClockWrapper.getAccurateTime() + recurringDelay;
  executing=false;
switch (priority) {
case High:
synchronized (highPriorityLock) {
      if (running) {
        ClockWrapper.stopForcingUpdate();
        try {
          ClockWrapper.updateClock();
          highPriorityQueue.reposition(this);
        }
  finally {
          ClockWrapper.resumeForcingUpdate();
        }
      }
    }
  break;
case Low:
synchronized (lowPriorityLock) {
  if (running) {
    ClockWrapper.stopForcingUpdate();
    try {
      ClockWrapper.updateClock();
      lowPriorityQueue.reposition(this);
    }
  finally {
      ClockWrapper.resumeForcingUpdate();
    }
  }
}
break;
default :
throw new UnsupportedOperationException("String_Node_Str" + priority);
}
}

Fixed version (ground truth):
private void reschedule(){
  nextRunTime=ClockWrapper.getAccurateTime() + recurringDelay;
switch (priority) {
case High:
synchronized (highPriorityLock) {
      if (running) {
        ClockWrapper.stopForcingUpdate();
        try {
          ClockWrapper.updateClock();
          highPriorityQueue.reposition(this,getNextDelayInMillis());
        }
  finally {
          ClockWrapper.resumeForcingUpdate();
        }
      }
    }
  break;
case Low:
synchronized (lowPriorityLock) {
  if (running) {
    ClockWrapper.stopForcingUpdate();
    try {
      ClockWrapper.updateClock();
      lowPriorityQueue.reposition(this,getNextDelayInMillis());
    }
  finally {
      ClockWrapper.resumeForcingUpdate();
    }
  }
}
break;
default :
throw new UnsupportedOperationException("String_Node_Str" + priority);
}
executing=false;
}
Program: 161765
Project: 161765
Buggy source:
/** 
 * Called to reposition an item in the queue which's delay has updated since original insertion (or was originally inserted as addLast().
 * @param e item currently in the queue
 */
public void reposition(T e){
  if (e == null) {
    return;
  }
synchronized (queueLock) {
    int insertionIndex=ListUtils.getInsertionEndIndex(queue,e,randomAccessQueue);
    queue.reposition(e,insertionIndex,true);
    queueLock.signalAll();
  }
}

Fixed version (ground truth):
/** 
 * Called to reposition an item in the queue which's delay wants to be updated since original insertion (or was originally inserted as addLast()). It is expected that this function will be called to reposition before the items  delay time is updated in the .getDelay(TimeUnit) call.  After this function the  provided item should update it's delay to the one provided here immediately.
 * @param e item currently in the queue
 * @param newDelayInMillis delay time that e will be updated to after reposition
 */
public void reposition(T e,long newDelayInMillis){
  if (e == null) {
    return;
  }
synchronized (queueLock) {
    int insertionIndex=ListUtils.getInsertionEndIndex(queue,newDelayInMillis,randomAccessQueue);
    queue.reposition(e,insertionIndex,true);
    queueLock.signalAll();
  }
}
Program: 161767
Project: 161767
Buggy source:
/** 
 * This function uses the binary search and adds a small amount of logic such that it determines the placement index for a given item.  It is  designed to always place the item after any existing items that match the  key's delay.
 * @param list List to search entries for placement
 * @param key key for searching placement of
 * @param randomAccessList boolean for optimization with binary search
 * @return the index to insert the key into the list
 */
public static int getInsertionEndIndex(List<? extends Delayed> list,Delayed key,boolean randomAccessList){
  int searchResult=binarySearch(list,key,randomAccessList);
  if (searchResult >= 0) {
    long keyDelay=key.getDelay(TimeUnit.MILLISECONDS);
    Iterator<? extends Delayed> it=list.listIterator(searchResult);
    while (it.hasNext() && it.next().getDelay(TimeUnit.MILLISECONDS) == keyDelay) {
      searchResult++;
    }
    return searchResult;
  }
 else {
    return Math.abs(searchResult) - 1;
  }
}

Fixed version (ground truth):
/** 
 * This function uses the binary search and adds a small amount of logic such that it determines the placement index for a given item.  It is  designed to always place the item after any existing items that match the  key's delay.
 * @param list List to search entries for placement
 * @param insertionValueInMillis delay time in milliseconds to search for insertion point
 * @param randomAccessList boolean for optimization with binary search
 * @return the index to insert the key into the list
 */
public static int getInsertionEndIndex(List<? extends Delayed> list,long insertionValueInMillis,boolean randomAccessList){
  int searchResult=binarySearch(list,insertionValueInMillis,randomAccessList);
  if (searchResult >= 0) {
    Iterator<? extends Delayed> it=list.listIterator(searchResult);
    while (it.hasNext() && it.next().getDelay(TimeUnit.MILLISECONDS) == insertionValueInMillis) {
      searchResult++;
    }
    return searchResult;
  }
 else {
    return Math.abs(searchResult) - 1;
  }
}
Program: 161768
Project: 161768
Buggy source:
@Override public boolean add(T e){
  if (e == null) {
    return false;
  }
synchronized (queueLock) {
    int insertionIndex=ListUtils.getInsertionEndIndex(queue,e,randomAccessQueue);
    queue.add(insertionIndex,e);
    queueLock.notify();
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean add(T e){
  if (e == null) {
    return false;
  }
synchronized (queueLock) {
    int insertionIndex=ListUtils.getInsertionEndIndex(queue,e,randomAccessQueue);
    queue.add(insertionIndex,e);
    queueLock.signal();
  }
  return true;
}
Program: 161769
Project: 161769
Buggy source:
@Override public int drainTo(Collection<? super T> c,int maxElements){
  if (maxElements <= 0) {
    return 0;
  }
  int addedElements=0;
  while (addedElements < maxElements && peek() != null) {
    c.add(poll());
    addedElements++;
  }
  return addedElements;
}

Fixed version (ground truth):
@Override public int drainTo(Collection<? super T> c,int maxElements){
  if (maxElements <= 0) {
    return 0;
  }
  int addedElements=0;
synchronized (queueLock) {
    while (addedElements < maxElements && peek() != null) {
      c.add(poll());
      addedElements++;
    }
  }
  return addedElements;
}
Program: 161770
Project: 161770
Buggy source:
@Override public int drainTo(Collection<? super T> c,int maxElements){
  if (maxElements <= 0) {
    return 0;
  }
  int addedElements=0;
  T next=poll();
  while (addedElements < maxElements && next != null) {
    c.add(next);
    addedElements++;
    next=poll();
  }
  return addedElements;
}

Fixed version (ground truth):
@Override public int drainTo(Collection<? super T> c,int maxElements){
  if (maxElements <= 0) {
    return 0;
  }
  int addedElements=0;
  while (addedElements < maxElements && peek() != null) {
    c.add(poll());
    addedElements++;
  }
  return addedElements;
}
Program: 161771
Project: 161771
Buggy source:
@Override public T pollFirst(){
synchronized (modificationLock) {
    T result=peekFirst();
    if (result != null) {
      currentData=currentData.remove(size() - 1);
    }
    return result;
  }
}

Fixed version (ground truth):
@Override public T pollFirst(){
synchronized (modificationLock) {
    T result=peekFirst();
    if (result != null) {
      currentData=currentData.remove(0);
    }
    return result;
  }
}
Program: 161772
Project: 161772
Buggy source:
@Override public <T>T invokeAny(Collection<? extends Callable<T>> tasks,long timeout,TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
  return invokeAny(tasks,timeout,unit);
}

Fixed version (ground truth):
@Override public <T>T invokeAny(Collection<? extends Callable<T>> tasks,long timeout,TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
  throw new UnsupportedOperationException();
}
Program: 161773
Project: 161773
Buggy source:
@Override public <T>List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks,long timeout,TimeUnit unit) throws InterruptedException {
  long startTime=Clock.accurateTime();
  long timeoutInMs=TimeUnit.MILLISECONDS.convert(timeout,unit);
  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();
      FutureRunnable<T> fr=new FutureRunnable<T>(c);
      resultList.add(fr);
      scheduler.execute(fr);
    }
  }
{
    Iterator<Future<T>> it=resultList.iterator();
    long remainingTime=Math.max(0,timeoutInMs - (Clock.accurateTime() - 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.accurateTime() - startTime));
    }
  }
  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.accurateTime();
  long timeoutInMs=TimeUnit.MILLISECONDS.convert(timeout,unit);
  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();
      }
      FutureRunnable<T> fr=new FutureRunnable<T>(c);
      resultList.add(fr);
      scheduler.execute(fr);
    }
  }
{
    Iterator<Future<T>> it=resultList.iterator();
    long remainingTime=Math.max(0,timeoutInMs - (Clock.accurateTime() - 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.accurateTime() - startTime));
    }
  }
  return resultList;
}
Program: 161774
Project: 161774
Buggy source:
public static void invokeAllTest(ScheduledExecutorService scheduler){
}

Fixed version (ground truth):
public static void invokeAllTest(ScheduledExecutorService scheduler) throws InterruptedException, ExecutionException {
  int callableQty=10;
  List<TestCallable> toInvoke=new ArrayList<TestCallable>(callableQty);
  for (int i=0; i < callableQty; i++) {
    toInvoke.add(new TestCallable(0));
  }
  List<Future<Object>> result=scheduler.invokeAll(toInvoke);
  assertEquals(result.size(),toInvoke.size());
  Iterator<TestCallable> it=toInvoke.iterator();
  Iterator<Future<Object>> resultIt=result.iterator();
  while (it.hasNext()) {
    assertTrue(resultIt.next().get() == it.next().result);
  }
}
Program: 161775
Project: 161775
Buggy source:
@Override public int drainTo(Collection<? super T> c,int maxElements){
  int addedElements=0;
  T next=poll();
  while (addedElements < maxElements && next != null) {
    c.add(next);
    addedElements++;
    next=poll();
  }
  return addedElements;
}

Fixed version (ground truth):
@Override public int drainTo(Collection<? super T> c,int maxElements){
  if (maxElements <= 0) {
    return 0;
  }
  int addedElements=0;
  T next=poll();
  while (addedElements < maxElements && next != null) {
    c.add(next);
    addedElements++;
    next=poll();
  }
  return addedElements;
}
Program: 161777
Project: 161777
Buggy source:
public void maybeStart(){
  if (started) {
    return;
  }
synchronized (queueLock) {
    if (started) {
      return;
    }
    started=true;
    runningThread=new Thread(this);
    runningThread.setDaemon(USE_DAEMON_THREADS);
    runningThread.setName("String_Node_Str");
    runningThread.start();
  }
}

Fixed version (ground truth):
public void maybeStart(){
  if (started) {
    return;
  }
synchronized (queueLock) {
    if (started) {
      return;
    }
    started=true;
    runningThread=threadFactory.newThread(this);
    runningThread.setDaemon(true);
    runningThread.setName("String_Node_Str");
    runningThread.start();
  }
}
Program: 161778
Project: 161778
Buggy source:
protected Worker getExistingWorker(long maxWaitForLowPriorityInMs) throws InterruptedException {
synchronized (workersLock) {
    long startTime=ClockWrapper.getAccurateTime();
    long waitTime=maxWaitForLowPriorityInMs;
    while (availableWorkers.isEmpty() && waitTime > 0) {
      if (waitTime == Long.MAX_VALUE) {
        workersLock.await();
      }
 else {
        long elapsedTime=ClockWrapper.getAccurateTime() - startTime;
        waitTime=maxWaitForLowPriorityInMs - elapsedTime;
        workersLock.await(waitTime);
      }
    }
    if (availableWorkers.isEmpty()) {
      return null;
    }
 else {
      return availableWorkers.removeFirst();
    }
  }
}

Fixed version (ground truth):
protected Worker getExistingWorker(long maxWaitForLowPriorityInMs) throws InterruptedException {
synchronized (workersLock) {
    long startTime=ClockWrapper.getAccurateTime();
    long waitTime=maxWaitForLowPriorityInMs;
    while (availableWorkers.isEmpty() && waitTime > 0) {
      if (waitTime == Long.MAX_VALUE) {
        workersLock.await();
      }
 else {
        long elapsedTime=ClockWrapper.getAccurateTime() - startTime;
        waitTime=maxWaitForLowPriorityInMs - elapsedTime;
        if (waitTime > 0) {
          workersLock.await(waitTime);
        }
      }
    }
    if (availableWorkers.isEmpty()) {
      return null;
    }
 else {
      return availableWorkers.removeFirst();
    }
  }
}
Program: 161779
Project: 161779
Buggy source:
@Override public Thread newThread(Runnable runnable){
  Thread thread=defaultFactory.newThread(runnable);
  thread.setDaemon(USE_DAEMON_THREADS);
  return thread;
}

Fixed version (ground truth):
@Override public Thread newThread(Runnable runnable){
  Thread thread=defaultFactory.newThread(runnable);
  thread.setDaemon(useDaemonThreads);
  return thread;
}
Program: 161780
Project: 161780
Buggy source:
@Test public void repositionNormalMoveMiddleTest(){
  DataSet<Integer> result=orderedNormal.reposition(1,0);
  Integer[] expectedResult=new Integer[]{1,0,2,3,4,5,6,7,8,9};
  System.out.println(result);
  assertTrue(result.equals(getDataSet(expectedResult,0,expectedResult.length)));
  result=orderedNormal.reposition(1,5);
  expectedResult=new Integer[]{0,2,3,4,1,5,6,7,8,9};
  assertTrue(result.equals(getDataSet(expectedResult,0,expectedResult.length)));
  result=orderedNormal.reposition(5,1);
  expectedResult=new Integer[]{0,5,1,2,3,4,6,7,8,9};
  assertTrue(result.equals(getDataSet(expectedResult,0,expectedResult.length)));
  result=orderedNormal.reposition(1,10);
  expectedResult=new Integer[]{0,2,3,4,5,6,7,8,9,1};
  assertTrue(result.equals(getDataSet(expectedResult,0,expectedResult.length)));
}

Fixed version (ground truth):
@Test public void repositionNormalMoveMiddleTest(){
  DataSet<Integer> result=orderedNormal.reposition(1,0);
  Integer[] expectedResult=new Integer[]{1,0,2,3,4,5,6,7,8,9};
  assertTrue(result.equals(getDataSet(expectedResult,0,expectedResult.length)));
  result=orderedNormal.reposition(1,5);
  expectedResult=new Integer[]{0,2,3,4,1,5,6,7,8,9};
  assertTrue(result.equals(getDataSet(expectedResult,0,expectedResult.length)));
  result=orderedNormal.reposition(5,1);
  expectedResult=new Integer[]{0,5,1,2,3,4,6,7,8,9};
  assertTrue(result.equals(getDataSet(expectedResult,0,expectedResult.length)));
  result=orderedNormal.reposition(1,10);
  expectedResult=new Integer[]{0,2,3,4,5,6,7,8,9,1};
  assertTrue(result.equals(getDataSet(expectedResult,0,expectedResult.length)));
}
Program: 161781
Project: 161781
Buggy source:
protected void blockTillAvailable() throws InterruptedException {
synchronized (queueLock) {
    while (queue.isEmpty()) {
      queueLock.await();
    }
    long nextDelay=-1;
    while ((nextDelay=queue.getFirst().getDelay(TimeUnit.MILLISECONDS)) > 0) {
      if (nextDelay > 5) {
        queueLock.await(nextDelay);
      }
    }
  }
}

Fixed version (ground truth):
protected void blockTillAvailable() throws InterruptedException {
synchronized (queueLock) {
    while (true) {
      if (queue.isEmpty()) {
        queueLock.await();
      }
      T next=queue.getFirst();
      long nextDelay=next.getDelay(TimeUnit.MILLISECONDS);
      if (nextDelay > 5) {
        queueLock.await(nextDelay);
      }
 else       if (nextDelay > 0) {
        long startTime=ClockWrapper.getAccurateTime();
        long startDelay=nextDelay;
        while ((nextDelay=next.getDelay(TimeUnit.MILLISECONDS)) > 0 && (nextDelay != startDelay || ClockWrapper.getAccurateTime() < startTime + 5)) {
        }
        if (nextDelay > 0) {
          queueLock.await(nextDelay);
        }
      }
 else {
        return;
      }
    }
  }
}
Program: 161782
Project: 161782
Buggy source:
private RunnableContainer getNextTask(long nowInMs){
synchronized (queueLock) {
    RunnableContainer firstResult=null;
    long nextDelay=Long.MIN_VALUE;
    Iterator<RunnableContainer> it=taskQueue.iterator();
    while (it.hasNext() && nextDelay <= 0) {
      RunnableContainer next=it.next();
      nextDelay=next.getDelay(nowInMs,TimeUnit.MILLISECONDS);
      if (nextDelay <= 0) {
        if (firstResult == null) {
          if (next.priority == TaskPriority.Low) {
            firstResult=next;
          }
 else {
            it.remove();
            return next;
          }
        }
 else         if (next.priority == TaskPriority.High) {
          it.remove();
          return next;
        }
      }
    }
    taskQueue.removeFirst();
    return firstResult;
  }
}

Fixed version (ground truth):
private RunnableContainer getNextTask(long nowInMs){
synchronized (queueLock) {
    RunnableContainer firstResult=null;
    long nextDelay=Long.MIN_VALUE;
    Iterator<RunnableContainer> it=taskQueue.iterator();
    while (it.hasNext() && nextDelay <= 0) {
      RunnableContainer next=it.next();
      nextDelay=next.getDelay(nowInMs,TimeUnit.MILLISECONDS);
      if (nextDelay <= 0) {
        if (firstResult == null) {
          if (next.priority == TaskPriority.Low) {
            firstResult=next;
          }
 else {
            it.remove();
            return next;
          }
        }
 else         if (next.priority == TaskPriority.High) {
          it.remove();
          return next;
        }
      }
    }
    if (firstResult != null) {
      taskQueue.removeFirst();
    }
    return firstResult;
  }
}
Program: 161783
Project: 161783
Buggy source:
@After public void tearDown(){
  testScheduler=null;
  parentScheduler=null;
  parentScheduler.shutdown();
}

Fixed version (ground truth):
@After public void tearDown(){
  testScheduler=null;
  parentScheduler.shutdown();
  parentScheduler=null;
}
Program: 161789
Project: 161789
Buggy source:
public static int findNumHops(int[] array){
  if (array == null) {
    throw new NullPointerException("String_Node_Str");
  }
  Set<Integer> steps=new HashSet<Integer>();
  int lastSeenStep=array.length - 1;
  steps.add(lastSeenStep);
  for (int index=array.length - 2; index >= 0; index--) {
    int hopSize=array[index];
    int reachableStep=hopSize + index;
    if (steps.contains(reachableStep)) {
      for (Iterator<Integer> iter=steps.iterator(); iter.hasNext(); ) {
        int step=iter.next();
        if (step < reachableStep) {
          iter.remove();
        }
      }
      steps.add(index);
      lastSeenStep=index;
    }
  }
  return steps.size() - 1 + lastSeenStep;
}

Fixed version (ground truth):
public static int findNumHops(int[] array){
  if (array == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (array.length == 0) {
    return 0;
  }
  Set<Integer> steps=new HashSet<Integer>();
  int lastSeenStep=array.length - 1;
  steps.add(lastSeenStep);
  for (int index=array.length - 2; index >= 0; index--) {
    int hopSize=array[index];
    int reachableStep=hopSize + index;
    if (steps.contains(reachableStep)) {
      for (Iterator<Integer> iter=steps.iterator(); iter.hasNext(); ) {
        int step=iter.next();
        if (step < reachableStep) {
          iter.remove();
        }
      }
      steps.add(index);
      lastSeenStep=index;
    }
  }
  return steps.size() - 1 + lastSeenStep;
}
Program: 161790
Project: 161790
Buggy source:
public synchronized void add(T element) throws InterruptedException {
  long threadId=Thread.currentThread().getId();
  writerQueue.add(threadId);
  while (writerQueue.size() == capacity || writerQueue.peek() != threadId) {
    wait();
  }
  writerQueue.remove();
  elementQueue.add(element);
  notifyAll();
}

Fixed version (ground truth):
public synchronized void add(T element) throws InterruptedException {
  long threadId=Thread.currentThread().getId();
  writerQueue.add(threadId);
  while (elementQueue.size() == capacity || writerQueue.peek() != threadId) {
    wait();
  }
  writerQueue.remove();
  elementQueue.add(element);
  notifyAll();
}
Program: 161791
Project: 161791
Buggy source:
public static int findNumHops(int[] array){
  if (array == null) {
    throw new NullPointerException("String_Node_Str");
  }
  Set<Integer> steps=new HashSet<Integer>();
  steps.add(array.length - 1);
  int lastSeenStep=array.length - 1;
  for (int index=array.length - 2; index >= 0; index--) {
    int hopSize=array[index];
    int reachableStep=hopSize + index;
    if (steps.contains(reachableStep)) {
      for (Iterator<Integer> iter=steps.iterator(); iter.hasNext(); ) {
        int step=iter.next();
        if (step < reachableStep) {
          iter.remove();
        }
      }
      steps.add(index);
      lastSeenStep=index;
    }
  }
  return steps.size() - 2 + lastSeenStep;
}

Fixed version (ground truth):
public static int findNumHops(int[] array){
  if (array == null) {
    throw new NullPointerException("String_Node_Str");
  }
  Set<Integer> steps=new HashSet<Integer>();
  int lastSeenStep=array.length - 1;
  steps.add(lastSeenStep);
  for (int index=array.length - 2; index >= 0; index--) {
    int hopSize=array[index];
    int reachableStep=hopSize + index;
    if (steps.contains(reachableStep)) {
      for (Iterator<Integer> iter=steps.iterator(); iter.hasNext(); ) {
        int step=iter.next();
        if (step < reachableStep) {
          iter.remove();
        }
      }
      steps.add(index);
      lastSeenStep=index;
    }
  }
  return steps.size() - 1 + lastSeenStep;
}
Program: 161792
Project: 161792
Buggy source:
public void setCapacity(int capacity){
  checkCapacity(capacity);
  this.capacity=capacity;
}

Fixed version (ground truth):
public void setCapacity(int capacity){
  checkCapacity(capacity);
  for (int count=cache.size(); count > capacity; count--) {
    CacheNode<K,V> evicted=evict();
    cache.remove(evicted.getKey());
  }
  this.capacity=capacity;
}
Program: 161794
Project: 161794
Buggy source:
protected void zoomTo(float scale,int x,int y){
  if (getScale() * scale < mMinScale) {
    return;
  }
  if (scale >= 1 && getScale() * scale > MAX_SCALE) {
    return;
  }
  mMatrix.postScale(scale,scale);
  mMatrix.postTranslate(-(getWidth() * scale - getWidth()) / 2,-(getHeight() * scale - getHeight()) / 2);
  mMatrix.postTranslate(-(x - (getWidth() / 2)) * scale,0);
  mMatrix.postTranslate(0,-(y - (getHeight() / 2)) * scale);
  setImageMatrix(mMatrix);
}

Fixed version (ground truth):
protected void zoomTo(float scale,int x,int y){
  if (getScale() * scale < mMinScale) {
    return;
  }
  if (scale >= 1 && getScale() * scale > MAX_SCALE) {
    return;
  }
  mMatrix.postScale(scale,scale);
  mMatrix.postTranslate(-(mWidth * scale - mWidth) / 2,-(mHeight * scale - mHeight) / 2);
  mMatrix.postTranslate(-(x - (mWidth / 2)) * scale,0);
  mMatrix.postTranslate(0,-(y - (mHeight / 2)) * scale);
  setImageMatrix(mMatrix);
}
Program: 161795
Project: 161795
Buggy source:
@Override protected boolean setFrame(int l,int t,int r,int b){
  mMatrix.reset();
  mScale=(float)r / (float)mIntrinsicWidth;
  int paddingHeight=0;
  int paddingWidth=0;
  if (mScale * mIntrinsicHeight > b) {
    mScale=(float)b / (float)mIntrinsicHeight;
    int width=(int)((float)mScale * (float)mIntrinsicWidth);
    mMatrix.postScale(mScale,mScale);
    paddingWidth=(r - width) / 2;
    paddingHeight=0;
  }
 else {
    mMatrix.postScale(mScale,mScale);
    int height=(int)((float)mScale * (float)mIntrinsicHeight);
    paddingHeight=(b - height) / 2;
    paddingWidth=0;
  }
  mMatrix.postTranslate(paddingWidth,paddingHeight);
  setImageMatrix(mMatrix);
  mMinScale=mScale;
  return super.setFrame(l,t,r,b);
}

Fixed version (ground truth):
@Override protected boolean setFrame(int l,int t,int r,int b){
  mWidth=r - l;
  mHeight=b - t;
  mMatrix.reset();
  mScale=(float)r / (float)mIntrinsicWidth;
  int paddingHeight=0;
  int paddingWidth=0;
  if (mScale * mIntrinsicHeight > mHeight) {
    mScale=(float)mHeight / (float)mIntrinsicHeight;
    mMatrix.postScale(mScale,mScale);
    paddingWidth=(r - mWidth) / 2;
    paddingHeight=0;
  }
 else {
    mMatrix.postScale(mScale,mScale);
    paddingHeight=(b - mHeight) / 2;
    paddingWidth=0;
  }
  mMatrix.postTranslate(paddingWidth,paddingHeight);
  setImageMatrix(mMatrix);
  mMinScale=mScale;
  zoomTo(mScale,mWidth / 2,mHeight / 2);
  cutting();
  return super.setFrame(l,t,r,b);
}
Program: 161796
Project: 161796
Buggy source:
public void cutting(){
  int width=(int)(mIntrinsicWidth * getScale());
  int height=(int)(mIntrinsicHeight * getScale());
  if (getTranslateX() < -(width - getWidth())) {
    mMatrix.postTranslate(-(getTranslateX() + width - getWidth()),0);
  }
  if (getTranslateX() > 0) {
    mMatrix.postTranslate(-getTranslateX(),0);
  }
  if (getTranslateY() < -(height - getHeight())) {
    mMatrix.postTranslate(0,-(getTranslateY() + height - getHeight()));
  }
  if (getTranslateY() > 0) {
    mMatrix.postTranslate(0,-getTranslateY());
  }
  if (width < getWidth()) {
    mMatrix.postTranslate((getWidth() - width) / 2,0);
  }
  if (height < getHeight()) {
    mMatrix.postTranslate(0,(getHeight() - height) / 2);
  }
  setImageMatrix(mMatrix);
}

Fixed version (ground truth):
public void cutting(){
  int width=(int)(mIntrinsicWidth * getScale());
  int height=(int)(mIntrinsicHeight * getScale());
  if (getTranslateX() < -(width - mWidth)) {
    mMatrix.postTranslate(-(getTranslateX() + width - mWidth),0);
  }
  if (getTranslateX() > 0) {
    mMatrix.postTranslate(-getTranslateX(),0);
  }
  if (getTranslateY() < -(height - mHeight)) {
    mMatrix.postTranslate(0,-(getTranslateY() + height - mHeight));
  }
  if (getTranslateY() > 0) {
    mMatrix.postTranslate(0,-getTranslateY());
  }
  if (width < mWidth) {
    mMatrix.postTranslate((mWidth - width) / 2,0);
  }
  if (height < mHeight) {
    mMatrix.postTranslate(0,(mHeight - height) / 2);
  }
  setImageMatrix(mMatrix);
}
Program: 161797
Project: 161797
Buggy source:
private float dispDistance(){
  return FloatMath.sqrt(getWidth() * getWidth() + getHeight() * getHeight());
}

Fixed version (ground truth):
private float dispDistance(){
  return FloatMath.sqrt(mWidth * mWidth + mHeight * mHeight);
}
Program: 161799
Project: 161799
Buggy source:
private MagicEntries readEntriesFromResource(String resource) throws IOException {
  InputStream stream=getClass().getResourceAsStream(resource);
  if (stream == null) {
    throw new FileNotFoundException("String_Node_Str" + resource);
  }
  Reader reader=null;
  try {
    if (resource.endsWith("String_Node_Str")) {
      reader=new InputStreamReader(new GZIPInputStream(new BufferedInputStream(stream)));
    }
 else {
      reader=new InputStreamReader(new BufferedInputStream(stream));
    }
    stream=null;
    return readEntries(reader);
  }
  finally {
    closeQuietly(reader);
    closeQuietly(stream);
  }
}

Fixed version (ground truth):
private MagicEntries readEntriesFromResource(String resource) throws IOException {
  InputStream stream=getClass().getResourceAsStream(resource);
  if (stream == null) {
    return null;
  }
  Reader reader=null;
  try {
    if (resource.endsWith("String_Node_Str")) {
      reader=new InputStreamReader(new GZIPInputStream(new BufferedInputStream(stream)));
    }
 else {
      reader=new InputStreamReader(new BufferedInputStream(stream));
    }
    stream=null;
    return readEntries(reader);
  }
  finally {
    closeQuietly(reader);
    closeQuietly(stream);
  }
}
Program: 161800
Project: 161800
Buggy source:
private Long convertNumber(int offset,byte[] bytes,int size,int shift,int mask){
  if (size != 4) {
    throw new UnsupportedOperationException("String_Node_Str");
  }
  if (offset + size > bytes.length) {
    return null;
  }
  long value=0;
  value=value << shift | (bytes[1] & mask);
  value=value << shift | (bytes[0] & mask);
  value=value << shift | (bytes[3] & mask);
  value=value << shift | (bytes[2] & mask);
  return value;
}

Fixed version (ground truth):
private Long convertNumber(int offset,byte[] bytes,int size,int shift,int mask){
  if (size != 4) {
    throw new UnsupportedOperationException("String_Node_Str");
  }
  if (offset + size > bytes.length) {
    return null;
  }
  long value=0;
  value=(value << shift) | (bytes[1] & mask);
  value=(value << shift) | (bytes[0] & mask);
  value=(value << shift) | (bytes[3] & mask);
  value=(value << shift) | (bytes[2] & mask);
  return value;
}
Program: 161801
Project: 161801
Buggy source:
@Override public Object extractValueFromBytes(int offset,byte[] bytes){
  int len;
  for (len=offset; len < bytes.length - 1; len+=2) {
    if (bytes[len] == 0 && bytes[len + 1] == 0) {
      break;
    }
  }
  char[] chars=new char[len / 2];
  for (int i=0; i < len; i++) {
    chars[i]=bytesToChar(bytes[i * 2],bytes[i * 2 + 1]);
  }
  return chars;
}

Fixed version (ground truth):
@Override public Object extractValueFromBytes(int offset,byte[] bytes){
  int len;
  for (len=offset; len < bytes.length - 1; len+=2) {
    if (bytes[len] == 0 && bytes[len + 1] == 0) {
      break;
    }
  }
  char[] chars=new char[len / 2];
  for (int i=0; i < chars.length; i++) {
    chars[i]=bytesToChar(bytes[i * 2],bytes[i * 2 + 1]);
  }
  return chars;
}
Program: 161802
Project: 161802
Buggy source:
protected char bytesToChar(int firstByte,int secondByte){
  return (char)(firstByte << 8 + secondByte);
}

Fixed version (ground truth):
/** 
 * Convert 2 bytes into a character.
 */
protected char bytesToChar(int firstByte,int secondByte){
  return (char)((firstByte << 8) + secondByte);
}
Program: 161803
Project: 161803
Buggy source:
@Override protected char bytesToChar(int firstByte,int secondByte){
  return (char)(secondByte << 8 + firstByte);
}

Fixed version (ground truth):
@Override protected char bytesToChar(int firstByte,int secondByte){
  return (char)((secondByte << 8) + firstByte);
}
Program: 161804
Project: 161804
Buggy source:
@Override public Object extractValueFromBytes(int offset,byte[] bytes){
  int len;
  for (len=offset; len < bytes.length - 1; len+=2) {
    if (bytes[len] == 0 && bytes[len + 1] == 0) {
      break;
    }
  }
  char[] chars=new char[len / 2];
  for (int i=0; i < chars.length; i++) {
    chars[i]=bytesToChar(bytes[i * 2],bytes[i * 2 + 1]);
  }
  return chars;
}

Fixed version (ground truth):
@Override public Object extractValueFromBytes(int offset,byte[] bytes,boolean required){
  int len;
  for (len=offset; len < bytes.length - 1; len+=2) {
    if (bytes[len] == 0 && bytes[len + 1] == 0) {
      break;
    }
  }
  char[] chars=new char[len / 2];
  for (int i=0; i < chars.length; i++) {
    chars[i]=bytesToChar(bytes[i * 2],bytes[i * 2 + 1]);
  }
  return chars;
}
Program: 161805
Project: 161805
Buggy source:
@Test public void testStuff(){
  BigEndianString16Type type=new BigEndianString16Type();
  char[] value=(char[])type.extractValueFromBytes(0,new byte[]{1,'a',2,'b'});
  assertEquals("String_Node_Str",new String(value));
}

Fixed version (ground truth):
@Test public void testStuff(){
  BigEndianString16Type type=new BigEndianString16Type();
  byte[] bytes=new byte[]{1,'a',2,'b'};
  char[] value=(char[])type.extractValueFromBytes(0,bytes,true);
  assertEquals("String_Node_Str",new String(value));
}
Program: 161806
Project: 161806
Buggy source:
@Test public void testStuff(){
  LittleEndianString16Type type=new LittleEndianString16Type();
  char[] value=(char[])type.extractValueFromBytes(0,new byte[]{1,'a',2,'b'});
  System.out.println((int)value[0]);
  assertEquals("String_Node_Str",new String(value));
}

Fixed version (ground truth):
@Test public void testStuff(){
  LittleEndianString16Type type=new LittleEndianString16Type();
  byte[] bytes=new byte[]{1,'a',2,'b'};
  char[] value=(char[])type.extractValueFromBytes(0,bytes,true);
  System.out.println((int)value[0]);
  assertEquals("String_Node_Str",new String(value));
}
Program: 161807
Project: 161807
Buggy source:
/** 
 * Optimize the magic entries by removing the first-bytes information into their own lists
 */
public void optimizeFirstBytes(){
  levelNexts=null;
  MagicEntry[] firstByteNexts=new MagicEntry[firstByteLinkedLists.length];
  MagicEntry previousNonFirstByteEntry=null;
  MagicEntry next;
  for (MagicEntry entry=entryLinkedList; entry != null; entry=next) {
    byte[] startingBytes=entry.getStartsWithByte();
    if (startingBytes == null || startingBytes.length == 0) {
      if (previousNonFirstByteEntry == null) {
        entryLinkedList=entry;
      }
 else {
        previousNonFirstByteEntry.setNext(entry);
      }
      previousNonFirstByteEntry=entry;
    }
 else {
      int index=(0xFF & startingBytes[0]);
      if (firstByteNexts[index] == null) {
        firstByteLinkedLists[index]=entry;
      }
 else {
        firstByteNexts[index].setNext(entry);
      }
      firstByteNexts[index]=entry;
    }
    next=entry.getNext();
    entry.setNext(null);
  }
}

Fixed version (ground truth):
/** 
 * Optimize the magic entries by removing the first-bytes information into their own lists
 */
public void optimizeFirstBytes(){
  levelNexts=null;
  MagicEntry[] firstByteNexts=new MagicEntry[firstByteLinkedLists.length];
  MagicEntry previousNonFirstByteEntry=null;
  MagicEntry next;
  for (MagicEntry entry=entryLinkedList; entry != null; entry=next) {
    byte[] startingBytes=entry.getStartsWithByte();
    if (startingBytes == null || startingBytes.length == 0) {
      if (previousNonFirstByteEntry == null) {
        entryLinkedList=entry;
      }
 else {
        previousNonFirstByteEntry.setNext(entry);
      }
      previousNonFirstByteEntry=entry;
    }
 else {
      if (entry.leaveInMatchList()) {
        entry=entry.clone();
      }
      int index=(0xFF & startingBytes[0]);
      if (firstByteNexts[index] == null) {
        firstByteLinkedLists[index]=entry;
      }
 else {
        firstByteNexts[index].setNext(entry);
      }
      firstByteNexts[index]=entry;
    }
    next=entry.getNext();
    entry.setNext(null);
  }
}
Program: 161808
Project: 161808
Buggy source:
public byte[] getStartingBytes(){
  if (pattern.length() < 4) {
    return null;
  }
 else {
    return new byte[]{(byte)pattern.charAt(0),(byte)pattern.charAt(1),(byte)pattern.charAt(2),(byte)pattern.charAt(3)};
  }
}

Fixed version (ground truth):
/** 
 * Get the bytes that start the pattern from an optimization standpoint. 
 */
public byte[] getStartingBytes(){
  if (pattern.length() < 4) {
    return null;
  }
 else {
    return new byte[]{(byte)pattern.charAt(0),(byte)pattern.charAt(1),(byte)pattern.charAt(2),(byte)pattern.charAt(3)};
  }
}
Program: 161809
Project: 161809
Buggy source:
private void readFile(List<MagicEntry> entryList,Reader reader) throws IOException {
  BufferedReader lineReader=new BufferedReader(reader);
  MagicEntry previous=null;
  while (true) {
    String line=lineReader.readLine();
    if (line == null) {
      return;
    }
    if (line.length() == 0 || line.charAt(0) == '#') {
      continue;
    }
    MagicEntry entry;
    try {
      entry=MagicEntry.parseString(previous,line);
    }
 catch (    IllegalArgumentException e) {
      continue;
    }
    if (entry == null) {
      continue;
    }
    if (entry.getLevel() == 0) {
      entryList.add(entry);
    }
    previous=entry;
  }
}

Fixed version (ground truth):
private void readFile(List<MagicEntry> entryList,Reader reader) throws IOException {
  BufferedReader lineReader=new BufferedReader(reader);
  MagicEntry previous=null;
  while (true) {
    String line=lineReader.readLine();
    if (line == null) {
      return;
    }
    if (line.length() == 0 || line.charAt(0) == '#') {
      continue;
    }
    MagicEntry entry;
    try {
      entry=MagicEntry.parseLine(previous,line);
    }
 catch (    IllegalArgumentException e) {
      System.err.println("String_Node_Str" + e);
      continue;
    }
    if (entry == null) {
      continue;
    }
    if (entry.getLevel() == 0) {
      entryList.add(entry);
    }
    previous=entry;
  }
}
Program: 161810
Project: 161810
Buggy source:
private ContentInfo processBytes(byte[] bytes,ContentInfo contentInfo){
  Object val=matcher.extractValueFromBytes(offset,bytes);
  if (val == null) {
    return null;
  }
  if (testValue != null) {
    val=matcher.isMatch(testValue,andValue,unsignedType,val,offset,bytes);
    if (val == null) {
      return null;
    }
  }
  if (contentInfo == null) {
    contentInfo=new ContentInfo(name,mimeType);
  }
  if (formatter != null) {
    if (formatSpacePrefix && contentInfo.sb.length() > 0) {
      contentInfo.sb.append(' ');
    }
    matcher.renderValue(contentInfo.sb,val,formatter);
  }
  if (children != null) {
    boolean matched=false;
    for (    MagicEntry child : children) {
      if (child.processBytes(bytes,contentInfo) != null) {
        matched=true;
        if (contentInfo.name == UNKNOWN_NAME && child.name != null) {
          contentInfo.name=child.name;
        }
        if (contentInfo.mimeType == null && child.mimeType != null) {
          contentInfo.mimeType=child.mimeType;
        }
      }
    }
    if (!matched) {
      contentInfo=null;
    }
  }
  return contentInfo;
}

Fixed version (ground truth):
private ContentInfo processBytes(byte[] bytes,ContentInfo contentInfo){
  Object val=matcher.extractValueFromBytes(offset,bytes);
  if (val == null) {
    return null;
  }
  if (testValue != null) {
    val=matcher.isMatch(testValue,andValue,unsignedType,val,offset,bytes);
    if (val == null) {
      return null;
    }
  }
  if (contentInfo == null) {
    contentInfo=new ContentInfo(name,mimeType);
  }
  if (formatter != null) {
    if (formatSpacePrefix && contentInfo.sb.length() > 0) {
      contentInfo.sb.append(' ');
    }
    matcher.renderValue(contentInfo.sb,val,formatter);
  }
  if (children != null) {
    boolean matched=false;
    boolean assignName=(contentInfo.name == UNKNOWN_NAME);
    for (    MagicEntry child : children) {
      if (child.processBytes(bytes,contentInfo) != null) {
        matched=true;
        if (assignName && child.name != null && child.name != UNKNOWN_NAME) {
          contentInfo.name=child.name;
        }
        if (contentInfo.mimeType == null && child.mimeType != null) {
          contentInfo.mimeType=child.mimeType;
        }
      }
    }
    if (!matched) {
      return null;
    }
  }
  return contentInfo;
}
Program: 161811
Project: 161811
Buggy source:
/** 
 * Converts the test-string from the magic line to be an object to be passed into  {@link #isMatch(Object,int,byte[])}.
 */
public Object convertTestString(String test,int offset);

Fixed version (ground truth):
/** 
 * Converts the test-string from the magic line to be an object to be passed into  {@link #isMatch(Object,int,byte[])}.
 */
public Object convertTestString(String typeStr,String testStr,int offset);
Program: 161812
Project: 161812
Buggy source:
public Object convertTestString(String test,int offset){
  return EMPTY;
}

Fixed version (ground truth):
public Object convertTestString(String typeStr,String testStr,int offset){
  return EMPTY;
}
Program: 161813
Project: 161813
Buggy source:
public Object convertTestString(String test,int offset){
  try {
    return Double.parseDouble(test);
  }
 catch (  NumberFormatException e) {
    throw new IllegalArgumentException("String_Node_Str" + test);
  }
}

Fixed version (ground truth):
public Object convertTestString(String typeStr,String testStr,int offset){
  try {
    return Double.parseDouble(testStr);
  }
 catch (  NumberFormatException e) {
    throw new IllegalArgumentException("String_Node_Str" + testStr);
  }
}
Program: 161814
Project: 161814
Buggy source:
public Object convertTestString(String test,int offset){
  try {
    return Float.parseFloat(test);
  }
 catch (  NumberFormatException e) {
    throw new IllegalArgumentException("String_Node_Str" + test);
  }
}

Fixed version (ground truth):
public Object convertTestString(String typeStr,String testStr,int offset){
  try {
    return Float.parseFloat(testStr);
  }
 catch (  NumberFormatException e) {
    throw new IllegalArgumentException("String_Node_Str" + testStr);
  }
}
Program: 161815
Project: 161815
Buggy source:
@Override public Long extractValueFromBytes(int offset,byte[] bytes){
  return endianConverter.convertNumber(offset,bytes,4);
}

Fixed version (ground truth):
@Override public Object extractValueFromBytes(int offset,byte[] bytes){
  return endianConverter.convertNumber(offset,bytes,4);
}
Program: 161816
Project: 161816
Buggy source:
@Override public void renderValue(StringBuilder sb,Object extractedValue,Formatter formatter){
  long val=(Integer)extractedValue;
  val*=1000;
  Calendar calendar=Calendar.getInstance();
  calendar.setTimeInMillis(val);
  sb.append(dateFormat.get().format(calendar));
}

Fixed version (ground truth):
@Override public void renderValue(StringBuilder sb,Object extractedValue,Formatter formatter){
  long val=(Long)extractedValue;
  formatter.format(sb,dateFormat.get().format(dateFromExtractedValue(val)));
}
Program: 161817
Project: 161817
Buggy source:
public Object convertTestString(String test,int offset){
  return new NumberOperator(test);
}

Fixed version (ground truth):
public Object convertTestString(String typeStr,String testStr,int offset){
  return new NumberOperator(testStr);
}
Program: 161818
Project: 161818
Buggy source:
public Object convertTestString(String test,int offset){
  int index=test.lastIndexOf('/');
  PatternInfo patternInfo=new PatternInfo();
  if (index >= 0 && (index == test.length() - 2 || index == test.length() - 3)) {
    boolean valid=handleFlag(patternInfo,test.charAt(index + 1));
    if (valid && index == test.length() - 3) {
      valid=handleFlag(patternInfo,test.charAt(index + 2));
    }
    if (valid) {
      test=test.substring(0,index);
    }
  }
  patternInfo.pattern=Pattern.compile("String_Node_Str" + test + "String_Node_Str",patternInfo.patternFlags);
  return patternInfo;
}

Fixed version (ground truth):
public Object convertTestString(String typeStr,String testStr,int offset){
  Matcher matcher=TYPE_PATTERN.matcher(typeStr);
  PatternInfo patternInfo=new PatternInfo();
  if (matcher.matches()) {
    String flagsStr=matcher.group(1);
    if (flagsStr != null && flagsStr.length() > 1) {
      for (      char ch : flagsStr.toCharArray()) {
        if (ch == 'c') {
          patternInfo.patternFlags|=Pattern.CASE_INSENSITIVE;
        }
 else         if (ch == 's') {
          patternInfo.updateOffsetStart=true;
        }
      }
    }
  }
  patternInfo.pattern=Pattern.compile("String_Node_Str" + testStr + "String_Node_Str",patternInfo.patternFlags);
  return patternInfo;
}
Program: 161819
Project: 161819
Buggy source:
@Override public Object isMatch(Object testValue,Long andValue,boolean unsignedType,Object extractedValue,int offset,byte[] bytes){
  StringTestInfo info=(StringTestInfo)testValue;
  BufferedReader reader=new BufferedReader(new InputStreamReader(new ByteArrayInputStream(bytes)));
  try {
    int lineCount;
    for (lineCount=0; lineCount < offset; lineCount++) {
      if (reader.readLine() == null) {
        return null;
      }
    }
    for (; lineCount < info.maxOffset; lineCount++) {
      String line=reader.readLine();
      if (line == null) {
        break;
      }
      for (int i=0; i < line.length(); i++) {
        String match=findOffsetMatch(info,i,null,line);
        if (match != null) {
          return match;
        }
      }
    }
    return null;
  }
 catch (  IOException e) {
    return null;
  }
}

Fixed version (ground truth):
@Override public Object isMatch(Object testValue,Long andValue,boolean unsignedType,Object extractedValue,int offset,byte[] bytes){
  if (offset > MAX_NUM_LINES) {
    return false;
  }
  StringTestInfo info=(StringTestInfo)testValue;
  BufferedReader reader=new BufferedReader(new InputStreamReader(new ByteArrayInputStream(bytes)));
  try {
    int lineCount;
    for (lineCount=0; lineCount < offset; lineCount++) {
      if (reader.readLine() == null) {
        return null;
      }
    }
    for (; lineCount < info.maxOffset; lineCount++) {
      String line=reader.readLine();
      if (line == null) {
        break;
      }
      for (int i=0; i < line.length(); i++) {
        String match=findOffsetMatch(info,i,null,line);
        if (match != null) {
          return match;
        }
      }
    }
    return null;
  }
 catch (  IOException e) {
    return null;
  }
}