nus-yam/ex-repair huggingface dataset:
Program: 32767
Project: 32767
Buggy source:
/** 
 * Handles a change in a remote resource.
 */
public void remoteUpdate(PeerConnection publisher,PeerBlock block){
  if (block.getUpdateId() != (updateId + 1))   throw new IllegalStateException();
  if (block.getSessionId() != peerBlockFactory.getSessionId())   throw new IllegalStateException();
  resource.update(block.getPayload());
}

Fixed version (ground truth):
/** 
 * Handles a change in a remote resource.
 */
public void remoteUpdate(PeerConnection publisher,PeerBlock block){
  if (publisher != null)   updateId++;
  if (block.getUpdateId() != updateId)   throw new IllegalStateException("String_Node_Str" + updateId + "String_Node_Str"+ block.getUpdateId());
  if (block.getSessionId() != peerBlockFactory.getSessionId())   throw new IllegalStateException();
  resource.update(block.getPayload());
}
Program: 32768
Project: 32768
Buggy source:
public int read(){
  ByteBuffer readBuffer=getReadFromBuffer();
  if (readBuffer == null)   return -1;
  byte result=readBuffer.get();
  doneReading();
  return result;
}

Fixed version (ground truth):
public int read(){
  ByteBuffer readBuffer=getReadFromBuffer();
  if (readBuffer == null)   return -1;
  int result=0xFF & readBuffer.get();
  doneReading();
  return result;
}
Program: 32769
Project: 32769
Buggy source:
/** 
 * Gets a new buffer by creating it or removing it from the pool.
 */
private ByteBuffer getNewBuffer(){
  int BUFFER_SIZE=8 * 1024;
  return ByteBuffer.allocateDirect(BUFFER_SIZE);
}

Fixed version (ground truth):
/** 
 * Gets a new buffer by creating it or removing it from the pool.
 */
private ByteBuffer getNewBuffer(){
  int BUFFER_SIZE=8196;
  return ByteBuffer.allocateDirect(BUFFER_SIZE);
}
Program: 32770
Project: 32770
Buggy source:
/** 
 * Tests that a snapshot can be decoded.
 */
public void testSnapshotDecode() throws IOException {
  EventList toEncode=new BasicEventList();
  EventEncoderListener encoder=new EventEncoderListener(intCoder);
  toEncode.addListEventListener(encoder);
  EventList toDecode=new BasicEventList();
  toDecode.add(new Integer(1));
  toDecode.add(new Integer(2));
  toDecode.add(new Integer(4));
  List entireList=Arrays.asList(new Object[]{new Integer(8),new Integer(6),new Integer(7),new Integer(5),new Integer(3),new Integer(0),new Integer(9)});
  toEncode.addAll(entireList);
  Bufferlo entireListEncoding=(Bufferlo)encoder.getEncodings().remove(0);
  ListEventCoder.bytesToListEvent(entireListEncoding,toDecode,intCoder);
  assertEquals(toEncode,toDecode);
}

Fixed version (ground truth):
/** 
 * Tests that a snapshot can be decoded.
 */
public void testSnapshotDecode() throws IOException {
  EventList toEncode=new BasicEventList();
  EventList toDecode=new BasicEventList();
  toDecode.add(new Integer(1));
  toDecode.add(new Integer(2));
  toDecode.add(new Integer(4));
  List entireList=Arrays.asList(new Object[]{new Integer(8),new Integer(6),new Integer(7),new Integer(5),new Integer(3),new Integer(0),new Integer(9)});
  toEncode.addAll(entireList);
  Bufferlo entireListEncoding=ListEventCoder.listToBytes(toEncode,intCoder);
  ListEventCoder.bytesToListEvent(entireListEncoding,toDecode,intCoder);
  assertEquals(toEncode,toDecode);
}
Program: 32771
Project: 32771
Buggy source:
/** 
 * Compares two <code>Object</code>s, and compares them using the result given when each <code>Object</code> is evaluated using the underlying <code>ThresholdEvaluator</code>. <p>This method is dual-mode as in the case of the Objects passed being <code>Integer</code>s, it returns the value of <code>((Integer)alpha).intValue() - ((Integer)beta).intValue()</code>. This is necessary so that a threshold value can be compared against an <code>Object</code>, and vice versa.  This can cause problems however if the underlying <code>ThresholdEvaluator</code> were to return the negation of an <code>Integer</code>.
 */
public int compare(Object alpha,Object beta){
  int alphaValue=0;
  if (alpha instanceof Integer)   alphaValue=((Integer)alpha).intValue();
 else   alphaValue=evaluator.evaluate(alpha);
  int betaValue=0;
  if (beta instanceof Integer)   betaValue=((Integer)beta).intValue();
 else   betaValue=evaluator.evaluate(beta);
  return alphaValue - betaValue;
}

Fixed version (ground truth):
/** 
 * Compares two <code>Object</code>s, and compares them using the result given when each <code>Object</code> is evaluated using the underlying <code>ThresholdEvaluator</code>. <p>This method is dual-mode as in the case of the Objects passed being <code>Integer</code>s, it returns the value of <code>((Integer)alpha).intValue() - ((Integer)beta).intValue()</code>. This is necessary so that a threshold value can be compared against an <code>Object</code>, and vice versa.  This can cause problems however if the underlying <code>ThresholdEvaluator</code> were to return the negation of an <code>Integer</code>.
 */
public int compare(Object alpha,Object beta){
  int alphaValue=0;
  if (alpha instanceof Integer)   alphaValue=((Integer)alpha).intValue();
 else   alphaValue=evaluator.evaluate(alpha);
  int betaValue=0;
  if (beta instanceof Integer)   betaValue=((Integer)beta).intValue();
 else   betaValue=evaluator.evaluate(beta);
  if (alphaValue > betaValue)   return 1;
 else   if (alphaValue < betaValue)   return -1;
 else   return 0;
}
Program: 32772
Project: 32772
Buggy source:
/** 
 * Sets the upper threshold for this list. <p><strong><font color="#FF0000">Warning:</font></strong> This method is thread ready but not thread safe. See   {@link EventList} for an exampleof thread safe code.
 */
public void setUpperThreshold(int threshold){
  int newListIndex=0;
  if (sourceSize == 0) {
    upperThreshold=threshold;
    upperThresholdIndex=-1;
    return;
  }
 else   if (threshold == upperThreshold) {
    return;
  }
 else {
    newListIndex=((SortedList)source).indexOfSimulated(new Integer(threshold + 1)) - 1;
  }
  upperThreshold=threshold;
  if (newListIndex == upperThresholdIndex) {
    return;
  }
  if ((newListIndex == -1 && upperThresholdIndex == 0) || (newListIndex == 0 && upperThresholdIndex == -1) || (newListIndex == size() && upperThresholdIndex == size() - 1)|| (newListIndex == size() - 1 && upperThresholdIndex == size())) {
    upperThresholdIndex=newListIndex;
    return;
  }
  updates.beginEvent();
  if (newListIndex < upperThresholdIndex) {
    updates.addDelete(newListIndex + 1,upperThresholdIndex - Math.max(lowerThresholdIndex,0));
  }
 else   if (newListIndex > upperThresholdIndex) {
    updates.addInsert(upperThresholdIndex - Math.max(lowerThresholdIndex,0) + 1,newListIndex);
  }
  upperThresholdIndex=newListIndex;
  updates.commitEvent();
}

Fixed version (ground truth):
/** 
 * Sets the upper threshold for this list. <p><strong><font color="#FF0000">Warning:</font></strong> This method is thread ready but not thread safe. See   {@link EventList} for an exampleof thread safe code.
 */
public void setUpperThreshold(int threshold){
  int newListIndex=0;
  if (sourceSize == 0) {
    upperThreshold=threshold;
    upperThresholdIndex=-1;
    return;
  }
 else   if (threshold == upperThreshold) {
    return;
  }
 else {
    if (threshold == Integer.MAX_VALUE) {
      newListIndex=sourceSize - 1;
    }
 else {
      newListIndex=((SortedList)source).indexOfSimulated(new Integer(threshold + 1)) - 1;
    }
  }
  upperThreshold=threshold;
  if (newListIndex == upperThresholdIndex) {
    return;
  }
  if ((newListIndex == -1 && upperThresholdIndex == 0) || (newListIndex == 0 && upperThresholdIndex == -1) || (newListIndex == size() && upperThresholdIndex == size() - 1)|| (newListIndex == size() - 1 && upperThresholdIndex == size())) {
    upperThresholdIndex=newListIndex;
    return;
  }
  updates.beginEvent();
  if (newListIndex < upperThresholdIndex) {
    updates.addDelete(newListIndex + 1,upperThresholdIndex - Math.max(lowerThresholdIndex,0));
  }
 else   if (newListIndex > upperThresholdIndex) {
    updates.addInsert(upperThresholdIndex - Math.max(lowerThresholdIndex,0) + 1,newListIndex);
  }
  upperThresholdIndex=newListIndex;
  updates.commitEvent();
}
Program: 32773
Project: 32773
Buggy source:
/** 
 * Compares two <code>Object</code>s, and compares them using the result given when each <code>Object</code> is evaluated using the underlying <code>ThresholdEvaluator</code>.
 */
public int compare(Object alpha,Object beta){
  int alphaValue=0;
  if (alpha instanceof Integer)   alphaValue=((Integer)alpha).intValue();
 else   alphaValue=evaluator.evaluate(alpha);
  int betaValue=0;
  if (beta instanceof Integer)   betaValue=((Integer)beta).intValue();
 else   betaValue=evaluator.evaluate(beta);
  return alphaValue - betaValue;
}

Fixed version (ground truth):
/** 
 * Compares two <code>Object</code>s, and compares them using the result given when each <code>Object</code> is evaluated using the underlying <code>ThresholdEvaluator</code>.
 */
public int compare(Object alpha,Object beta){
  int alphaValue=0;
  if (alpha instanceof Integer)   alphaValue=((Integer)alpha).intValue();
 else   alphaValue=evaluator.evaluate(alpha);
  int betaValue=0;
  if (beta instanceof Integer)   betaValue=((Integer)beta).intValue();
 else   betaValue=evaluator.evaluate(beta);
  if (alphaValue > betaValue)   return 1;
 else   if (alphaValue < betaValue)   return -1;
 else   return 0;
}
Program: 32775
Project: 32775
Buggy source:
/** 
 * Close the connection to the client.  <p>The closing behaviour is dictated by the current state of the connection and the reason for closing. <li>If the reason is an IOException, the socket is closed immediately <li>Otherwise a "goodbye" message is sent to notify the other party of the close <li>If the state is READY, the goodbye is a single 0-byte chunk <li>If the state is SERVER_AWAITING_REQUEST, the goodbye is a request error <li>If the state is RECEIVED_CLOSE, no goodbye message is sent
 * @return This method returns false because the connection is always in anunreadable and unwritable state after a close.
 */
boolean close(Exception reason){
  manager.invokeAndWait(new CTPConnectionToClose(this,reason));
  return false;
}

Fixed version (ground truth):
/** 
 * Close the connection to the client.  <p>The closing behaviour is dictated by the current state of the connection and the reason for closing. <li>If the reason is an IOException, the socket is closed immediately <li>Otherwise a "goodbye" message is sent to notify the other party of the close <li>If the state is READY, the goodbye is a single 0-byte chunk <li>If the state is SERVER_AWAITING_REQUEST, the goodbye is a request error <li>If the state is RECEIVED_CLOSE, no goodbye message is sent
 * @return This method returns false because the connection is always in anunreadable and unwritable state after a close.
 */
boolean close(Exception reason){
  manager.invokeLater(new CTPConnectionToClose(this,reason));
  return false;
}
Program: 32776
Project: 32776
Buggy source:
/** 
 * Fills the buffer with the contents of the channel. <p>This temporarily flips the buffer from read mode into write mode in order to add more bytes from the channel.
 * @return the number of bytes read, possibly 0 if there is nothing to read immediately
 * @throws IOException if the input buffer is full or if the end of the stream is reached
 */
private int suck() throws IOException {
  if (buffer.remaining() == buffer.capacity())   throw new IOException("String_Node_Str");
  buffer.compact();
  int bytesRead=channel.read(buffer);
  buffer.flip();
  if (bytesRead < 0)   throw new EOFException("String_Node_Str");
  return bytesRead;
}

Fixed version (ground truth):
/** 
 * Fills the buffer with the contents of the channel. <p>This temporarily flips the buffer from read mode into write mode in order to add more bytes from the channel.
 * @return the number of bytes read, possibly 0 if there is nothing to read immediately
 * @throws IOException if the input buffer is full or if the end of the stream is reached
 */
private int suck() throws IOException {
  if (buffer.remaining() == buffer.capacity())   throw new IOException("String_Node_Str");
  int bytesRead=suckle();
  if (bytesRead < 0)   throw new EOFException("String_Node_Str");
  return bytesRead;
}
Program: 32777
Project: 32777
Buggy source:
/** 
 * Calculate how many bytes are ready to be read immediately.
 */
public int bytesAvailable() throws IOException {
  while (buffer.remaining() < buffer.capacity()) {
    int bytesRead=suck();
    if (bytesRead == 0)     break;
  }
  return buffer.remaining();
}

Fixed version (ground truth):
/** 
 * Calculate how many bytes are ready to be read immediately.
 */
public int bytesAvailable() throws IOException {
  suckle();
  return buffer.remaining();
}
Program: 32778
Project: 32778
Buggy source:
private void sendEnqueued(CTPConnection connection){
  while (tasks.size() > 0 && tasks.get(0) instanceof Enqueued) {
    Enqueued enqueued=(Enqueued)tasks.remove(0);
    connection.sendChunk(enqueued.getData());
  }
}

Fixed version (ground truth):
private void sendEnqueued(CTPConnection connection){
  while (tasks.size() > 0 && tasks.get(0) instanceof Enqueued) {
    Enqueued enqueued=(Enqueued)tasks.remove(0);
    connection.sendChunk(enqueued.getData());
  }
  if (tasks.isEmpty()) {
    connection.close();
  }
}
Program: 32779
Project: 32779
Buggy source:
public void connectionClosed(CTPConnection source,Exception reason){
  if (!tasks.isEmpty())   throw new IllegalStateException();
}

Fixed version (ground truth):
public void connectionClosed(CTPConnection source,Exception reason){
  if (!tasks.isEmpty())   throw new IllegalStateException("String_Node_Str" + this + "String_Node_Str"+ tasks.size()+ "String_Node_Str"+ tasks);
}
Program: 32781
Project: 32781
Buggy source:
/** 
 * Handles whether this change index has a neighbour that existed prior to a current change and that the values are equal. This adjusts the duplicates list a found pair of such changes if they exist.
 * @return true if a neighbour was found and the duplicates list has beenupdated in response. returns false if the specified index has no such neighbour. In this case the value at the specified index will be marked as unique (but not temporarily so).
 */
private boolean handleOldNeighbour(int changeIndex){
  if (valuesEqual(changeIndex - 1,changeIndex)) {
    duplicatesList.set(changeIndex,DUPLICATE);
    return true;
  }
  int followerIndex=changeIndex + 1;
  while (true) {
    if (valuesEqual(changeIndex,followerIndex)) {
      Object followerType=duplicatesList.get(followerIndex);
      if (followerType == TEMP_UNIQUE) {
        followerIndex++;
      }
 else {
        duplicatesList.set(changeIndex,UNIQUE);
        duplicatesList.set(followerIndex,null);
        return true;
      }
    }
 else {
      duplicatesList.set(changeIndex,UNIQUE);
      return false;
    }
  }
}

Fixed version (ground truth):
/** 
 * Handles whether this change index has a neighbour that existed prior to a current change and that the values are equal. This adjusts the duplicates list a found pair of such changes if they exist.
 * @return NEIGHBOUR_NONE if no neighbour was found. In this case the value at the specifiedindex will be marked as unique, but not temporarily so. Returns NEIGHBOUR_LEFT if a neighbour was found on the left, and NEIGHBOUR_RIGHT if a neighbour was found on the right. In non-zero cases the duplicates list is updated.
 */
private int handleOldNeighbour(int changeIndex){
  if (valuesEqual(changeIndex - 1,changeIndex)) {
    duplicatesList.set(changeIndex,DUPLICATE);
    return NEIGHBOUR_LEFT;
  }
  int followerIndex=changeIndex + 1;
  while (true) {
    if (valuesEqual(changeIndex,followerIndex)) {
      Object followerType=duplicatesList.get(followerIndex);
      if (followerType == TEMP_UNIQUE) {
        followerIndex++;
      }
 else {
        duplicatesList.set(changeIndex,UNIQUE);
        duplicatesList.set(followerIndex,null);
        return NEIGHBOUR_RIGHT;
      }
    }
 else {
      duplicatesList.set(changeIndex,UNIQUE);
      return NEIGHBOUR_NONE;
    }
  }
}
Program: 32782
Project: 32782
Buggy source:
/** 
 * For implementing the ListEventListener interface.
 */
public void listChanged(ListEvent listChanges){
  if (verbose) {
    System.out.println(name + "String_Node_Str" + listChanges);
  }
  int highestChangeIndex=0;
  while (listChanges.next()) {
    int changeIndex=listChanges.getIndex();
    int changeType=listChanges.getType();
    if (changeIndex < highestChangeIndex) {
      new Exception(name + "String_Node_Str" + changeCount+ "String_Node_Str"+ changeIndex+ "String_Node_Str"+ highestChangeIndex+ "String_Node_Str"+ listChanges).printStackTrace();
    }
    highestChangeIndex=changeIndex;
    if (changeIndex < 0)     new Exception(name + "String_Node_Str" + changeCount+ "String_Node_Str"+ changeIndex+ "String_Node_Str"+ listChanges).printStackTrace();
    if (changeType == ListEvent.INSERT) {
      if (changeIndex > size)       new Exception(name + "String_Node_Str" + changeCount+ "String_Node_Str"+ changeIndex+ "String_Node_Str"+ size+ "String_Node_Str"+ listChanges).printStackTrace();
      size++;
    }
 else     if (changeType == ListEvent.DELETE) {
      if (changeIndex >= size)       new Exception(name + "String_Node_Str" + changeCount+ "String_Node_Str"+ changeIndex+ "String_Node_Str"+ size+ "String_Node_Str"+ listChanges).printStackTrace();
      size--;
    }
 else     if (changeType == ListEvent.UPDATE) {
      if (changeIndex >= size)       new Exception(name + "String_Node_Str" + changeCount+ "String_Node_Str"+ changeIndex+ "String_Node_Str"+ size+ "String_Node_Str"+ listChanges).printStackTrace();
    }
  }
  if (size != source.size()) {
    new Exception(name + "String_Node_Str" + changeCount+ "String_Node_Str"+ size+ "String_Node_Str"+ source.size()+ "String_Node_Str"+ listChanges).printStackTrace();
  }
  changeCount++;
}

Fixed version (ground truth):
/** 
 * For implementing the ListEventListener interface.
 */
public void listChanged(ListEvent listChanges){
  if (verbose)   System.out.println(name + "String_Node_Str" + listChanges);
  List changedIndices=new ArrayList();
  int highestChangeIndex=0;
  while (listChanges.next()) {
    int changeIndex=listChanges.getIndex();
    int changeType=listChanges.getType();
    changedIndices.add(new Integer(changeIndex));
    Assert.assertTrue(changeIndex >= 0);
    Assert.assertTrue(changeIndex >= highestChangeIndex);
    highestChangeIndex=changeIndex;
    if (changeType == ListEvent.INSERT) {
      expected.add(changeIndex,source.get(changeIndex));
    }
 else     if (changeType == ListEvent.DELETE) {
      expected.remove(changeIndex);
    }
 else     if (changeType == ListEvent.UPDATE) {
      expected.set(changeIndex,source.get(changeIndex));
    }
  }
  Assert.assertEquals(expected.size(),source.size());
  for (Iterator c=changedIndices.iterator(); c.hasNext(); ) {
    int changeIndex=((Integer)c.next()).intValue();
    for (int i=Math.max(changeIndex - 1,0); i < Math.min(changeIndex + 2,expected.size()); i++) {
      Assert.assertEquals(expected.get(i),source.get(i));
    }
  }
}
Program: 32783
Project: 32783
Buggy source:
/** 
 * Creates a new filter list that uses a TextFilterator. A TextFilterator is something that I made up. It is basically a class that knows how to take an arbitrary object and get an array of strings for that object.
 */
public TextFilterList(EventList source,Text filterEdit,TextFilterator filterator){
  super(source);
  this.filterEdit=filterEdit;
  this.filterator=filterator;
  filterModifyListener=new FilterModifyListener();
  filterEdit.addModifyListener(filterModifyListener);
  reFilter();
}

Fixed version (ground truth):
/** 
 * Creates a new filter list that uses a TextFilterator. A TextFilterator is something that I made up. It is basically a class that knows how to take an arbitrary object and get an array of strings for that object.
 */
public TextFilterList(EventList source,Text filterEdit,TextFilterator filterator){
  super(source,filterator);
  this.filterEdit=filterEdit;
  filterModifyListener=new FilterModifyListener();
  filterEdit.addModifyListener(filterModifyListener);
  reFilter();
}
Program: 32784
Project: 32784
Buggy source:
private PopularityList(EventList source,UniqueList uniqueList){
  super(new SortedList(uniqueList,new PopularityComparator(uniqueList)));
  uniqueList.setFireCountChangeEvents(true);
}

Fixed version (ground truth):
private PopularityList(EventList source,UniqueList uniqueList){
  super(new SortedList(uniqueList,new PopularityComparator(uniqueList)));
  this.uniqueList=uniqueList;
  uniqueList.setFireCountChangeEvents(true);
  ((SortedList)super.source).addListEventListener(this);
}
Program: 32785
Project: 32785
Buggy source:
/** 
 * {@inheritDoc} 
 */
public void dispose(){
  ((TransformedList)source).dispose();
  super.dispose();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public void dispose(){
  SortedList sortedSource=(SortedList)source;
  super.dispose();
  sortedSource.dispose();
  uniqueList.dispose();
}
Program: 32787
Project: 32787
Buggy source:
/** 
 * {@inheritDoc} 
 */
public void dispose(){
  ((TransformedList)source).dispose();
  super.dispose();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public void dispose(){
  SortedList sortedSource=(SortedList)source;
  super.dispose();
  sortedSource.dispose();
}
Program: 32788
Project: 32788
Buggy source:
/** 
 * Respond to a change in the source   {@link EventList} by updating the internalstate of this  {@link TransformedList}. If the state of this   {@link TransformedList}changes as a consequence, all interested   {@link ListEventListener}s will be notified in turn.
 */
public abstract void listChanged(ListEvent listChanges);

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public abstract void listChanged(ListEvent listChanges);
Program: 32789
Project: 32789
Buggy source:
/** 
 * Releases the resources consumed by this   {@link TransformedList} so that itmay eventually be garbage collected. <p>A  {@link TransformedList} will be garbage collected without a call to{@link #dispose()}, but not before its source   {@link EventList} is garbagecollected. By calling  {@link #dispose()}, you allow the   {@link TransformedList}to be garbage collected before its source   {@link EventList}. This is  necessary for situations where a   {@link TransformedList} is short-lived butits source  {@link EventList} is long-lived.<p><strong><font color="#FF0000">Warning:</font></strong> It is an error to call any method on a  {@link TransformedList} after it has been disposed.
 */
public void dispose(){
  source.removeListEventListener(this);
  source=null;
  readWriteLock=null;
}

Fixed version (ground truth):
/** 
 * Releases the resources consumed by this   {@link TransformedList} so that itmay eventually be garbage collected. <p>A  {@link TransformedList} will be garbage collected without a call to{@link #dispose()}, but not before its source   {@link EventList} is garbagecollected. By calling  {@link #dispose()}, you allow the   {@link TransformedList}to be garbage collected before its source   {@link EventList}. This is  necessary for situations where a   {@link TransformedList} is short-lived butits source  {@link EventList} is long-lived.<p><strong><font color="#FF0000">Warning:</font></strong> It is an error to call any method on a  {@link TransformedList} after it has been disposed.
 */
public void dispose(){
  source.removeListEventListener(this);
  source=null;
  readWriteLock=null;
  updates=null;
  publisher=null;
}
Program: 32791
Project: 32791
Buggy source:
/** 
 * Handles whether this change index has a neighbour that existed prior to a current change and that the values are equal. This adjusts the duplicates list a found pair of such changes if they exist.
 * @return true if a neighbour was found and the duplicates list has beenupdated in response. returns false if the specified index has no such neighbour. In this case the value at the specified index will be marked as unique (but not temporarily so).
 */
private boolean handleOldNeighbour(int changeIndex){
  if (valuesEqual(changeIndex - 1,changeIndex)) {
    duplicatesList.set(changeIndex,DUPLICATE);
    return true;
  }
  int followerIndex=changeIndex + 1;
  while (true) {
    if (valuesEqual(changeIndex,followerIndex)) {
      Object followerType=duplicatesList.get(followerIndex);
      if (followerType == TEMP_UNIQUE) {
        followerIndex++;
      }
 else {
        duplicatesList.set(changeIndex,UNIQUE);
        duplicatesList.set(followerIndex,null);
        return true;
      }
    }
 else {
      duplicatesList.set(changeIndex,UNIQUE);
      return false;
    }
  }
}

Fixed version (ground truth):
/** 
 * Handles whether this change index has a neighbour that existed prior to a current change and that the values are equal. This adjusts the duplicates list a found pair of such changes if they exist.
 * @return true if a neighbour was found and the duplicates list has beenupdated in response. returns false if the specified index has no such neighbour. In this case the value at the specified index will be marked as unique (but not temporarily so).
 * @return -1 if a neighbour was found on the left and the duplicates listhas been updated in response. Returns 1 if a neighbour was found on the right. Returns 0 if the specified index has no such neighbour. In this case the value at the specified index will be marked as unique (but not temporarily so).
 */
private int handleOldNeighbour(int changeIndex){
  if (valuesEqual(changeIndex - 1,changeIndex)) {
    duplicatesList.set(changeIndex,DUPLICATE);
    return -1;
  }
  int followerIndex=changeIndex + 1;
  while (true) {
    if (valuesEqual(changeIndex,followerIndex)) {
      Object followerType=duplicatesList.get(followerIndex);
      if (followerType == TEMP_UNIQUE) {
        followerIndex++;
      }
 else {
        duplicatesList.set(changeIndex,UNIQUE);
        duplicatesList.set(followerIndex,null);
        return 1;
      }
    }
 else {
      duplicatesList.set(changeIndex,UNIQUE);
      return 0;
    }
  }
}
Program: 32792
Project: 32792
Buggy source:
/** 
 * {@inheritDoc} 
 */
public void dispose(){
  ((TransformedList)source).dispose();
  super.dispose();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public void dispose(){
  SortedList sortedSource=(SortedList)source;
  super.dispose();
  sortedSource.dispose();
}
Program: 32793
Project: 32793
Buggy source:
/** 
 * Test that the Popularity List works with simple data.
 */
public void testSimpleData(){
  EventList source=new BasicEventList();
  PopularityList popularityList=new PopularityList(source);
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  assertEquals("String_Node_Str",popularityList.get(0));
  assertEquals("String_Node_Str",popularityList.get(1));
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  source.remove("String_Node_Str");
  source.remove("String_Node_Str");
  assertEquals("String_Node_Str",popularityList.get(0));
  assertEquals("String_Node_Str",popularityList.get(1));
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  assertEquals("String_Node_Str",popularityList.get(0));
  assertEquals("String_Node_Str",popularityList.get(1));
  assertEquals("String_Node_Str",popularityList.get(2));
  source.clear();
}

Fixed version (ground truth):
/** 
 * Test that the Popularity List works with simple data.
 */
public void testSimpleData(){
  EventList source=new BasicEventList();
  PopularityList popularityList=new PopularityList(source);
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  assertEquals("String_Node_Str",popularityList.get(0));
  assertEquals("String_Node_Str",popularityList.get(1));
  validateRanked(popularityList,source);
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  source.remove("String_Node_Str");
  source.remove("String_Node_Str");
  assertEquals("String_Node_Str",popularityList.get(0));
  assertEquals("String_Node_Str",popularityList.get(1));
  validateRanked(popularityList,source);
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  assertEquals("String_Node_Str",popularityList.get(0));
  assertEquals("String_Node_Str",popularityList.get(1));
  assertEquals("String_Node_Str",popularityList.get(2));
  validateRanked(popularityList,source);
  source.clear();
}
Program: 32796
Project: 32796
Buggy source:
/** 
 * Increments the change sequence to view the next change. This will return true if such a change exists and false when there is no change to view.
 */
public boolean next(){
  if (listChange == null || rowIndex == listChange.getEndIndex()) {
    return nextBlock();
  }
 else {
    rowIndex++;
    return true;
  }
}

Fixed version (ground truth):
/** 
 * Increments the change sequence to view the next change. This will return true if such a change exists and false when there is no change to view.
 */
public boolean next(){
  if (currentBlock == null || rowIndex == currentBlock.getEndIndex()) {
    return nextBlock();
  }
 else {
    assert(rowIndex < currentBlock.getEndIndex());
    rowIndex++;
    return true;
  }
}
Program: 32797
Project: 32797
Buggy source:
/** 
 * Gets the current row index. If the listChange type is delete, this will always return the startIndex of the current list change.
 */
public int getIndex(){
  if (listChange.getType() == DELETE)   return listChange.getStartIndex();
  return rowIndex;
}

Fixed version (ground truth):
/** 
 * Gets the current row index. If the block type is delete, this will always return the startIndex of the current list change.
 */
public int getIndex(){
  if (currentBlock.getType() == DELETE)   return currentBlock.getStartIndex();
  return rowIndex;
}
Program: 32798
Project: 32798
Buggy source:
/** 
 * Gets the number of blocks currently remaining in this atomic change.
 */
public int getBlocksRemaining(){
  if (listChange != null && rowIndex < listChange.getEndIndex()) {
    return masterSequence.getBlockCount(atomicCount) - blockCount + 1;
  }
 else {
    return masterSequence.getBlockCount(atomicCount) - blockCount;
  }
}

Fixed version (ground truth):
/** 
 * Gets the number of blocks currently remaining in this atomic change.
 */
public int getBlocksRemaining(){
  if (currentBlock != null && rowIndex < currentBlock.getEndIndex()) {
    return masterSequence.getBlockCount(atomicCount) - blockCount + 1;
  }
 else {
    return masterSequence.getBlockCount(atomicCount) - blockCount;
  }
}
Program: 32799
Project: 32799
Buggy source:
/** 
 * Without incrementing the implicit iterator, this tests if there is another change to view. The user will still need to call next() to view such a change.
 */
public boolean hasNext(){
  if (listChange == null || rowIndex == listChange.getEndIndex()) {
    if (atomicCount == masterSequence.getAtomicCount()) {
      return false;
    }
 else     if (blockCount == masterSequence.getBlockCount(atomicCount)) {
      return false;
    }
 else {
      return true;
    }
  }
 else {
    return true;
  }
}

Fixed version (ground truth):
/** 
 * Without incrementing the implicit iterator, this tests if there is another change to view. The user will still need to call next() to view such a change.
 */
public boolean hasNext(){
  if (currentBlock == null || rowIndex == currentBlock.getEndIndex()) {
    if (atomicCount == masterSequence.getAtomicCount()) {
      return false;
    }
 else     if (blockCount == masterSequence.getBlockCount(atomicCount)) {
      return false;
    }
 else {
      return true;
    }
  }
 else {
    return true;
  }
}
Program: 32800
Project: 32800
Buggy source:
/** 
 * Increments the change sequence to view the next change block.
 */
public boolean nextBlock(){
  if (blockCount == masterSequence.getBlockCount(atomicCount)) {
    listChange=null;
    rowIndex=-5;
    blockCount=0;
    if (atomicCount >= masterSequence.getAtomicCount()) {
      throw new NoSuchElementException("String_Node_Str");
    }
    atomicCount++;
    return false;
  }
 else {
    listChange=masterSequence.getBlock(atomicCount,blockCount);
    blockCount++;
    rowIndex=listChange.getStartIndex();
    return true;
  }
}

Fixed version (ground truth):
/** 
 * Increments the change sequence to view the next change block.
 */
public boolean nextBlock(){
  if (blockCount == masterSequence.getBlockCount(atomicCount)) {
    currentBlock=null;
    rowIndex=-5;
    blockCount=0;
    if (atomicCount >= masterSequence.getAtomicCount()) {
      throw new NoSuchElementException("String_Node_Str");
    }
    atomicCount++;
    return false;
  }
 else {
    currentBlock=masterSequence.getBlock(atomicCount,blockCount);
    blockCount++;
    rowIndex=currentBlock.getStartIndex();
    return true;
  }
}
Program: 32801
Project: 32801
Buggy source:
/** 
 * Gets the last row of the current block of changes. Inclusive.
 */
public int getBlockEndIndex(){
  return listChange.getEndIndex();
}

Fixed version (ground truth):
/** 
 * Gets the last row of the current block of changes. Inclusive.
 */
public int getBlockEndIndex(){
  return currentBlock.getEndIndex();
}
Program: 32802
Project: 32802
Buggy source:
/** 
 * Gets the reorder map of this list. This will also increment the change sequence to the next change.
 * @return an array of integers where the the previous index of a value isstored at the current index of that value.
 */
public int[] getReorderMap(){
  int[] reorderMap=masterSequence.getReorderMap(atomicCount);
  if (reorderMap == null)   throw new IllegalStateException("String_Node_Str");
  listChange=null;
  rowIndex=-5;
  blockCount=0;
  if (atomicCount >= masterSequence.getAtomicCount()) {
    throw new NoSuchElementException("String_Node_Str");
  }
  atomicCount++;
  return reorderMap;
}

Fixed version (ground truth):
/** 
 * Gets the reorder map of this list. This will also increment the change sequence to the next change.
 * @return an array of integers where the the previous index of a value isstored at the current index of that value.
 */
public int[] getReorderMap(){
  int[] reorderMap=masterSequence.getReorderMap(atomicCount);
  if (reorderMap == null)   throw new IllegalStateException("String_Node_Str");
  currentBlock=null;
  rowIndex=-5;
  blockCount=0;
  if (atomicCount >= masterSequence.getAtomicCount()) {
    throw new NoSuchElementException("String_Node_Str");
  }
  atomicCount++;
  return reorderMap;
}
Program: 32803
Project: 32803
Buggy source:
/** 
 * Creates a clone of this ListEvent, in order to iterate through the changes multiple times. You should always be sure to iterate through <strong>all</strong> values in the original instance in order to reach the freshest changes. <p>Because the master change sequence does not know about clones, it is possible that the change information stored in the master list will be cleaned up without notifying the clone. In order to prevent this, you should always use the clone list before using the original list - this way the existance of values in the original list guarantees that such values will be visible to the clone.
 */
public ListEvent(ListEvent original){
  super(original.sourceList);
  this.blockCount=original.blockCount;
  this.listChange=original.listChange;
  this.rowIndex=original.rowIndex;
  this.masterSequence=original.masterSequence;
  this.sourceList=original.sourceList;
  this.atomicCount=original.atomicCount;
}

Fixed version (ground truth):
/** 
 * Creates a clone of this ListEvent, in order to iterate through the changes multiple times. You should always be sure to iterate through <strong>all</strong> values in the original instance in order to reach the freshest changes. <p>Because the master change sequence does not know about clones, it is possible that the change information stored in the master list will be cleaned up without notifying the clone. In order to prevent this, you should always use the clone list before using the original list - this way the existance of values in the original list guarantees that such values will be visible to the clone.
 */
public ListEvent(ListEvent original){
  super(original.sourceList);
  this.blockCount=original.blockCount;
  this.currentBlock=original.currentBlock;
  this.rowIndex=original.rowIndex;
  this.masterSequence=original.masterSequence;
  this.sourceList=original.sourceList;
  this.atomicCount=original.atomicCount;
}
Program: 32804
Project: 32804
Buggy source:
/** 
 * Gets the type of the current change, which should be one of ListEvent.INSERT, UPDATE, or DELETE.
 */
public int getType(){
  return listChange.getType();
}

Fixed version (ground truth):
/** 
 * Gets the type of the current change, which should be one of ListEvent.INSERT, UPDATE, or DELETE.
 */
public int getType(){
  return currentBlock.getType();
}
Program: 32805
Project: 32805
Buggy source:
/** 
 * Gets the first row of the current block of changes. Inclusive.
 */
public int getBlockStartIndex(){
  return listChange.getStartIndex();
}

Fixed version (ground truth):
/** 
 * Gets the first row of the current block of changes. Inclusive.
 */
public int getBlockStartIndex(){
  return currentBlock.getStartIndex();
}
Program: 32806
Project: 32806
Buggy source:
/** 
 * Clears the queue of all unprocessed changes. This is used when a listener reloads the source list rather than modifying it by differences. <p>If the user is manually clearing the event queue with this method, it is also necessary to call hasNext() before calling next() when receiving new events. This is because it is possible that pending events will be cleared before they are processed. Otherwise the call to next() may fail.
 */
public void clearEventQueue(){
  atomicCount=masterSequence.getAtomicCount();
  listChange=null;
  blockCount=0;
}

Fixed version (ground truth):
/** 
 * Clears the queue of all unprocessed changes. This is used when a listener reloads the source list rather than modifying it by differences. <p>If the user is manually clearing the event queue with this method, it is also necessary to call hasNext() before calling next() when receiving new events. This is because it is possible that pending events will be cleared before they are processed. Otherwise the call to next() may fail.
 */
public void clearEventQueue(){
  atomicCount=masterSequence.getAtomicCount();
  currentBlock=null;
  blockCount=0;
}
Program: 32807
Project: 32807
Buggy source:
/** 
 * Sets the current event as a reordering. Reordering events cannot be combined with other events.
 */
public void reorder(int[] reorderMap){
  if (atomicChangeBlocks.size() > 0)   throw new IllegalStateException("String_Node_Str");
  addChange(ListEvent.DELETE,0,reorderMap.length - 1);
  addChange(ListEvent.INSERT,0,reorderMap.length - 1);
  this.reorderMap=reorderMap;
}

Fixed version (ground truth):
/** 
 * Sets the current event as a reordering. Reordering events cannot be combined with other events.
 */
public void reorder(int[] reorderMap){
  if (atomicChangeBlocks.size() > 0)   throw new IllegalStateException("String_Node_Str");
  if (reorderMap.length == 0)   return;
  addChange(ListEvent.DELETE,0,reorderMap.length - 1);
  addChange(ListEvent.INSERT,0,reorderMap.length - 1);
  this.reorderMap=reorderMap;
}
Program: 32808
Project: 32808
Buggy source:
/** 
 * Gets the object with the specified index in the tree, given the specified compressed index.
 */
public int getIndexByCompressedIndex(int compressedIndex){
  assert(compressedIndex >= treeLeftSize + treeRightSize + treeRootSize);
  if (compressedIndex < treeLeftSize) {
    return left.getIndexByCompressedIndex(compressedIndex);
  }
 else   if (compressedIndex < treeLeftSize + treeRootSize) {
    return totalLeftSize + virtualRootSize;
  }
 else {
    return right.getIndexByCompressedIndex(compressedIndex - (treeLeftSize + treeRootSize)) + totalLeftSize + treeRootSize+ virtualRootSize;
  }
}

Fixed version (ground truth):
/** 
 * Gets the object with the specified index in the tree, given the specified compressed index.
 */
public int getIndexByCompressedIndex(int compressedIndex){
  assert(compressedIndex <= treeLeftSize + treeRightSize + treeRootSize);
  if (compressedIndex < treeLeftSize) {
    return left.getIndexByCompressedIndex(compressedIndex);
  }
 else   if (compressedIndex < treeLeftSize + treeRootSize) {
    return totalLeftSize + virtualRootSize;
  }
 else {
    return right.getIndexByCompressedIndex(compressedIndex - (treeLeftSize + treeRootSize)) + totalLeftSize + treeRootSize+ virtualRootSize;
  }
}
Program: 32809
Project: 32809
Buggy source:
/** 
 * When there is a sequence of list changes, sometimes these changes are not created in increasing order. Users usually need to receive changes in increasing order, so it becomes necessary to reorder list change blocks. This returns true if two adjacent blocks are out of order.
 */
private static boolean requiresSwap(ListEventBlock first,ListEventBlock second){
  if (first.type == ListEvent.INSERT && second.type != ListEvent.INSERT) {
    if (first.endIndex >= second.startIndex && first.startIndex <= second.endIndex) {
      throw new IllegalStateException("String_Node_Str" + first + "String_Node_Str"+ second+ "String_Node_Str");
    }
  }
  if (second.type == ListEvent.INSERT) {
    return second.startIndex <= first.startIndex;
  }
 else {
    return second.startIndex < first.startIndex;
  }
}

Fixed version (ground truth):
/** 
 * When there is a sequence of list changes, sometimes these changes are not created in increasing order. Users usually need to receive changes in increasing order, so it becomes necessary to reorder list change blocks. This returns true if two adjacent blocks are out of order.
 */
private static boolean requiresSwap(ListEventBlock first,ListEventBlock second){
  if (first.type == ListEvent.INSERT && second.type != ListEvent.INSERT) {
    if (first.endIndex >= second.startIndex && first.startIndex <= second.endIndex) {
      throw new IllegalStateException("String_Node_Str" + first + "String_Node_Str"+ second+ "String_Node_Str");
    }
  }
  if (second.type == ListEvent.INSERT && first.type != ListEvent.DELETE) {
    return second.startIndex <= first.startIndex;
  }
 else {
    return second.startIndex < first.startIndex;
  }
}
Program: 32811
Project: 32811
Buggy source:
/** 
 * Gets the offset of the specified member list.
 */
private int getListOffset(MemberList memberList){
  int listOffset=0;
  for (int i=0; i < memberLists.size(); i++) {
    MemberList current=(MemberList)memberLists.get(i);
    if (current == memberList)     return listOffset;
 else     listOffset=listOffset + current.size();
  }
  throw new RuntimeException("String_Node_Str" + memberList);
}

Fixed version (ground truth):
/** 
 * Gets the offset of the specified member list.
 */
private int getListOffset(MemberList memberList){
  int listOffset=0;
  for (int i=0; i < memberLists.size(); i++) {
    MemberList current=(MemberList)memberLists.get(i);
    if (current == memberList)     return listOffset;
 else     listOffset=listOffset + current.size();
  }
  throw new IllegalStateException("String_Node_Str" + memberList);
}
Program: 32812
Project: 32812
Buggy source:
/** 
 * Creates a new WeakReferenceProxy that listens for events from the specified list and forwards them to the specified listener.
 */
public WeakReferenceProxy(EventList source,ListEventListener proxyTarget){
  if (source == null || proxyTarget == null)   throw new IllegalArgumentException();
  this.source=source;
  proxyTargetReference=new WeakReference(proxyTarget);
}

Fixed version (ground truth):
/** 
 * Creates a new WeakReferenceProxy that listens for events from the specified list and forwards them to the specified listener.
 */
public WeakReferenceProxy(EventList source,ListEventListener proxyTarget){
  if (source == null || proxyTarget == null)   throw new NullPointerException();
  this.source=source;
  proxyTargetReference=new WeakReference(proxyTarget);
}
Program: 32814
Project: 32814
Buggy source:
/** 
 * Validate the proper response to requested an index beyond <code>source.size() - 1</code>.  This test is included as a result of CachingList overriding get() from TransformedList.
 */
public void testBoundsErrorBehaviour(){
  boolean exceptionThrown=false;
  try {
    cache.get(26);
  }
 catch (  IndexOutOfBoundsException e) {
    exceptionThrown=true;
  }
catch (  Exception e) {
    exceptionThrown=true;
    fail("String_Node_Str" + e.getClass());
  }
 finally {
    if (exceptionThrown == false) {
      fail("String_Node_Str");
    }
  }
  for (int i=0; i < 25; i++) {
    source.add(new Integer(i));
  }
  exceptionThrown=false;
  try {
    cache.get(26);
  }
 catch (  IndexOutOfBoundsException e) {
    exceptionThrown=true;
  }
catch (  Exception e) {
    exceptionThrown=true;
    fail("String_Node_Str" + e.getClass());
  }
 finally {
    if (exceptionThrown == false) {
      fail("String_Node_Str");
    }
  }
  for (int i=9; i < 15; i++) {
    Object result=cache.get(i);
    assertEquals(new Integer(i),(Integer)result);
  }
  exceptionThrown=false;
  try {
    cache.get(26);
  }
 catch (  IndexOutOfBoundsException e) {
    exceptionThrown=true;
  }
catch (  Exception e) {
    exceptionThrown=true;
    fail("String_Node_Str" + e.getClass());
  }
 finally {
    if (exceptionThrown == false) {
      fail("String_Node_Str");
    }
  }
  for (int i=9; i < 15; i++) {
    Object result=cache.get(i);
    assertEquals(new Integer(i),(Integer)result);
  }
  exceptionThrown=false;
  try {
    cache.get(26);
  }
 catch (  IndexOutOfBoundsException e) {
    exceptionThrown=true;
  }
catch (  Exception e) {
    exceptionThrown=true;
    fail("String_Node_Str" + e.getClass());
  }
 finally {
    if (exceptionThrown == false) {
      fail("String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * Validate the proper response to requested an index beyond <code>source.size() - 1</code>.  This test is included as a result of CachingList overriding get() from TransformedList.
 */
public void testBoundsErrorBehaviour(){
  boolean exceptionThrown=false;
  try {
    cache.get(26);
  }
 catch (  IndexOutOfBoundsException e) {
    exceptionThrown=true;
  }
  if (exceptionThrown == false) {
    fail("String_Node_Str");
  }
  for (int i=0; i < 25; i++) {
    source.add(new Integer(i));
  }
  exceptionThrown=false;
  try {
    cache.get(26);
  }
 catch (  IndexOutOfBoundsException e) {
    exceptionThrown=true;
  }
  if (exceptionThrown == false) {
    fail("String_Node_Str");
  }
  for (int i=9; i < 15; i++) {
    Object result=cache.get(i);
    assertEquals(new Integer(i),(Integer)result);
  }
  exceptionThrown=false;
  try {
    cache.get(26);
  }
 catch (  IndexOutOfBoundsException e) {
    exceptionThrown=true;
  }
  if (exceptionThrown == false) {
    fail("String_Node_Str");
  }
  for (int i=9; i < 15; i++) {
    Object result=cache.get(i);
    assertEquals(new Integer(i),(Integer)result);
  }
  exceptionThrown=false;
  try {
    cache.get(26);
  }
 catch (  IndexOutOfBoundsException e) {
    exceptionThrown=true;
  }
  if (exceptionThrown == false) {
    fail("String_Node_Str");
  }
}
Program: 32815
Project: 32815
Buggy source:
private int getIndex(IndexedTreeNode child){
  if (child == left) {
    if (parent != null)     return parent.getIndex(this);
    return 0;
  }
  if (child == null) {
    if (parent != null)     return parent.getIndex(this) + leftSize;
    return leftSize;
  }
  if (child == right) {
    if (parent != null)     return parent.getIndex(this) + leftSize + rootSize;
    return leftSize + rootSize;
  }
  throw new IllegalArgumentException(this + "String_Node_Str");
}

Fixed version (ground truth):
private int getIndex(IndexedTreeNode child){
  if (child == left) {
    if (parent != null)     return parent.getIndex(this);
    return 0;
  }
  if (child == null) {
    if (parent != null)     return parent.getIndex(this) + leftSize;
    return leftSize;
  }
  if (child == right) {
    if (parent != null)     return parent.getIndex(this) + leftSize + rootSize;
    return leftSize + rootSize;
  }
  throw new IndexOutOfBoundsException(this + "String_Node_Str");
}