nus-yam/ex-repair huggingface dataset:
Program: 32854
Project: 32854
Buggy source:
/** 
 * Gets the index into the source list for the object with the specified index in this list.
 */
protected int getSourceIndex(int mutationIndex){
  return mutationIndex - startIndex;
}

Fixed version (ground truth):
/** 
 * Gets the index into the source list for the object with the specified index in this list.
 */
protected int getSourceIndex(int mutationIndex){
  return mutationIndex + startIndex;
}
Program: 32856
Project: 32856
Buggy source:
/** 
 * Tests that sorting works on a large set of filter changes.
 */
public void testAgressiveFiltering(){
  BasicEventList source=new BasicEventList();
  IntArrayFilterList filterList=new IntArrayFilterList(source);
  SortedList sorted=new SortedList(filterList,new IntArrayComparator(0));
  for (int i=0; i < 20; i++) {
    int value=random.nextInt(10);
    int[] array=new int[]{value,random.nextInt(2),random.nextInt(2),random.nextInt(2)};
    source.add(array);
  }
  for (int i=0; i < 100; i++) {
    int filterColumn=random.nextInt(3);
    filterList.setFilter(filterColumn + 1,1);
    ArrayList controlList=new ArrayList();
    controlList.addAll(filterList);
    Collections.sort(controlList,new IntArrayComparator(0));
    System.out.println("String_Node_Str" + sorted.size() + "String_Node_Str"+ controlList.size());
    System.out.print("String_Node_Str");
    for (int j=0; j < controlList.size(); j++) {
      System.out.print(((int[])controlList.get(j))[0] + "String_Node_Str");
    }
    System.out.println("String_Node_Str");
    System.out.print("String_Node_Str");
    for (int j=0; j < filterList.size(); j++) {
      System.out.print(((int[])filterList.get(j))[0] + "String_Node_Str");
    }
    System.out.println("String_Node_Str");
    System.out.print("String_Node_Str");
    for (int j=0; j < sorted.size(); j++) {
      System.out.print(((int[])sorted.get(j))[0] + "String_Node_Str");
    }
    System.out.println("String_Node_Str");
    assertEquals(sorted.size(),controlList.size());
    for (int j=0; j < sorted.size(); j++) {
      assertEquals(((int[])sorted.get(j))[0],((int[])controlList.get(j))[0]);
    }
  }
}

Fixed version (ground truth):
/** 
 * Tests that sorting works on a large set of filter changes.
 */
public void testAgressiveFiltering(){
  BasicEventList source=new BasicEventList();
  IntArrayFilterList filterList=new IntArrayFilterList(source);
  SortedList sorted=new SortedList(filterList,new IntArrayComparator(0));
  for (int i=0; i < 1000; i++) {
    int value=random.nextInt(1000);
    int[] array=new int[]{value,random.nextInt(2),random.nextInt(2),random.nextInt(2)};
    source.add(array);
  }
  for (int i=0; i < 10; i++) {
    int filterColumn=random.nextInt(3);
    filterList.setFilter(filterColumn + 1,1);
    ArrayList controlList=new ArrayList();
    controlList.addAll(filterList);
    Collections.sort(controlList,new IntArrayComparator(0));
    assertEquals(sorted.size(),controlList.size());
    for (int j=0; j < sorted.size(); j++) {
      assertEquals(((int[])sorted.get(j))[0],((int[])controlList.get(j))[0]);
    }
  }
}
Program: 32858
Project: 32858
Buggy source:
/** 
 * Commits the current atomic change to this list change queue. This will notify all listeners about the change.
 */
public synchronized void commitAtomicChange(){
  if (atomicChangeBlocks.size() > 0) {
    sortChangeBlocks(atomicChangeBlocks);
    atomicChanges.add(atomicChangeBlocks);
    changeCount=changeCount + atomicChangeCount;
    blockCount=blockCount + atomicChangeBlocks.size();
    for (int i=0; i < listeners.size(); i++) {
      ListChangeListener listener=(ListChangeListener)listeners.get(i);
      ListChangeEvent event=(ListChangeEvent)listenerEvents.get(i);
      listener.notifyListChanges(event);
    }
  }
  atomicChangeBlocks=null;
  atomicChangeCount=0;
  atomicLatestBlock=null;
}

Fixed version (ground truth):
/** 
 * Commits the current atomic change to this list change queue. This will notify all listeners about the change.
 */
public synchronized void commitAtomicChange(){
  if (atomicChangeBlocks.size() > 0) {
    ListChangeBlock.sortListChangeBlocks(atomicChangeBlocks);
    atomicChanges.add(atomicChangeBlocks);
    changeCount=changeCount + atomicChangeCount;
    blockCount=blockCount + atomicChangeBlocks.size();
    for (int i=0; i < listeners.size(); i++) {
      ListChangeListener listener=(ListChangeListener)listeners.get(i);
      ListChangeEvent event=(ListChangeEvent)listenerEvents.get(i);
      listener.notifyListChanges(event);
    }
  }
  atomicChangeBlocks=null;
  atomicChangeCount=0;
  atomicLatestBlock=null;
}
Program: 32860
Project: 32860
Buggy source:
/** 
 * Adds the specified list to the lists that compose this list.
 * @param index the index within the list of lists.
 */
public void addMemberList(EventList list){
synchronized (getRootList()) {
    MemberList memberList=new MemberList(list);
    memberLists.add(memberList);
    int offset=getListOffset(memberList);
    updates.beginAtomicChange();
    updates.appendChange(offset,offset + memberList.size() - 1,ListChangeBlock.INSERT);
    updates.commitAtomicChange();
  }
}

Fixed version (ground truth):
/** 
 * Adds the specified list to the lists that compose this list.
 */
public void addMemberList(EventList list){
synchronized (getRootList()) {
    MemberList memberList=new MemberList(list);
    memberLists.add(memberList);
    int offset=getListOffset(memberList);
    updates.beginAtomicChange();
    updates.appendChange(offset,offset + memberList.size() - 1,ListChangeBlock.INSERT);
    updates.commitAtomicChange();
  }
}
Program: 32861
Project: 32861
Buggy source:
/** 
 * Removes the specified list from the lists that compose this list.
 */
public void removeMemberList(EventList list){
synchronized (getRootList()) {
    MemberList memberList=null;
    for (int i=0; i < memberLists.size(); i++) {
      MemberList current=(MemberList)memberLists.get(i);
      if (current.getSourceList() == list) {
        memberList=current;
        break;
      }
    }
    if (memberList == null)     throw new IllegalArgumentException("String_Node_Str" + list + "String_Node_Str");
    int offset=getListOffset(memberList);
    memberLists.remove(memberList);
    updates.beginAtomicChange();
    updates.appendChange(offset,offset + memberList.size() - 1,ListChangeBlock.DELETE);
    updates.commitAtomicChange();
  }
}

Fixed version (ground truth):
/** 
 * Removes the specified list from the lists that compose this list.
 */
public void removeMemberList(EventList list){
synchronized (getRootList()) {
    MemberList memberList=null;
    for (int i=0; i < memberLists.size(); i++) {
      MemberList current=(MemberList)memberLists.get(i);
      if (current.getSourceList() == list) {
        memberList=current;
        break;
      }
    }
    if (memberList == null)     throw new IllegalArgumentException("String_Node_Str" + list + "String_Node_Str");
    int offset=getListOffset(memberList);
    memberLists.remove(memberList);
    if (memberList.size() > 0) {
      updates.beginAtomicChange();
      updates.appendChange(offset,offset + memberList.size() - 1,ListChangeBlock.DELETE);
      updates.commitAtomicChange();
    }
  }
}
Program: 32862
Project: 32862
Buggy source:
/** 
 * Adds the specified list to the lists that compose this list.
 */
public void addMemberList(EventList list){
synchronized (getRootList()) {
    MemberList memberList=new MemberList(list);
    memberLists.add(memberList);
    int offset=getListOffset(memberList);
    updates.beginAtomicChange();
    updates.appendChange(offset,offset + memberList.size() - 1,ListChangeBlock.INSERT);
    updates.commitAtomicChange();
  }
}

Fixed version (ground truth):
/** 
 * Adds the specified list to the lists that compose this list.
 */
public void addMemberList(EventList list){
synchronized (getRootList()) {
    MemberList memberList=new MemberList(list);
    memberLists.add(memberList);
    int offset=getListOffset(memberList);
    if (memberList.size() > 0) {
      updates.beginAtomicChange();
      updates.appendChange(offset,offset + memberList.size() - 1,ListChangeBlock.INSERT);
      updates.commitAtomicChange();
    }
  }
}
Program: 32863
Project: 32863
Buggy source:
/** 
 * Returns the element at the specified position in this list. Most mutation lists will override the get method to use a mapping.
 */
public Object get(int index){
synchronized (getRootList()) {
    for (int i=0; i < memberLists.size(); i++) {
      MemberList current=(MemberList)memberLists.get(i);
      if (index < current.size())       return current.getSourceList().get(index);
 else       index=index - current.size();
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Returns the element at the specified position in this list. Most mutation lists will override the get method to use a mapping.
 */
public Object get(int index){
synchronized (getRootList()) {
    for (int i=0; i < memberLists.size(); i++) {
      MemberList current=(MemberList)memberLists.get(i);
      if (index < current.size()) {
        return current.getSourceList().get(index);
      }
 else {
        index=index - current.size();
      }
    }
  }
  return null;
}
Program: 32864
Project: 32864
Buggy source:
/** 
 * Sets the FreezableList to be synchronized with the source list. This will allow the FreezableList to resume receiving updates from its source. When thawed the FreezableList will notify listening lists that the data has changed.
 */
public void thaw(){
synchronized (getRootList()) {
    if (!frozen)     throw new IllegalStateException("String_Node_Str");
    frozen=false;
    int frozenDataSize=frozenData.size();
    frozenData.clear();
    updates.beginAtomicChange();
    if (frozenData.size() > 0)     updates.appendChange(0,frozenDataSize - 1,ListChangeBlock.DELETE);
    if (source.size() > 0)     updates.appendChange(0,source.size() - 1,ListChangeBlock.INSERT);
    updates.commitAtomicChange();
    source.addListChangeListener(this);
  }
}

Fixed version (ground truth):
/** 
 * Sets the FreezableList to be synchronized with the source list. This will allow the FreezableList to resume receiving updates from its source. When thawed the FreezableList will notify listening lists that the data has changed.
 */
public void thaw(){
synchronized (getRootList()) {
    if (!frozen)     throw new IllegalStateException("String_Node_Str");
    frozen=false;
    int frozenDataSize=frozenData.size();
    frozenData.clear();
    updates.beginAtomicChange();
    if (frozenDataSize > 0)     updates.appendChange(0,frozenDataSize - 1,ListChangeBlock.DELETE);
    if (source.size() > 0)     updates.appendChange(0,source.size() - 1,ListChangeBlock.INSERT);
    updates.commitAtomicChange();
    source.addListChangeListener(this);
  }
}
Program: 32865
Project: 32865
Buggy source:
/** 
 * For implementing the ListChangeListener interface. This sends changes to the table which can repaint the table cells. Because this class uses a ListChangeListenerEventThreadProxy, it is guaranteed that all natural calls to this method use the Swing thread. This tests the size of the change to determine how to handle it. If the size of the change is greater than the changeSizeRepaintAllThreshhold, then the entire table is notified as changed. Otherwise only the descrete areas that changed are notified.
 */
public void notifyListChanges(ListChangeEvent listChanges){
  ignoreSelectionEvents=true;
  if (!listChanges.hasNext()) {
    return;
  }
 else   if (listChanges.getBlocksRemaining() >= changeSizeRepaintAllThreshhold) {
    listChanges.clearEventQueue();
    tableScrollPane.getViewport().setViewPosition(table.getCellRect(0,0,true).getLocation());
    fireTableDataChanged();
  }
 else {
    while (listChanges.nextBlock()) {
      int startIndex=listChanges.getBlockStartIndex();
      int endIndex=listChanges.getBlockEndIndex();
      int changeType=listChanges.getType();
      tableModelEvent.setValues(startIndex,endIndex,changeType);
      fireTableChanged(tableModelEvent);
    }
  }
  ignoreSelectionEvents=false;
  selectedIndex=-1;
  valueChanged(null);
}

Fixed version (ground truth):
/** 
 * For implementing the ListChangeListener interface. This sends changes to the table which can repaint the table cells. Because this class uses a ListChangeListenerEventThreadProxy, it is guaranteed that all natural calls to this method use the Swing thread. This tests the size of the change to determine how to handle it. If the size of the change is greater than the changeSizeRepaintAllThreshhold, then the entire table is notified as changed. Otherwise only the descrete areas that changed are notified.
 */
public void notifyListChanges(ListChangeEvent listChanges){
  if (!listChanges.hasNext())   return;
  ignoreSelectionEvents=true;
  if (listChanges.getBlocksRemaining() >= changeSizeRepaintAllThreshhold) {
    listChanges.clearEventQueue();
    tableScrollPane.getViewport().setViewPosition(table.getCellRect(0,0,true).getLocation());
    fireTableDataChanged();
  }
 else {
    while (listChanges.nextBlock()) {
      int startIndex=listChanges.getBlockStartIndex();
      int endIndex=listChanges.getBlockEndIndex();
      int changeType=listChanges.getType();
      tableModelEvent.setValues(startIndex,endIndex,changeType);
      fireTableChanged(tableModelEvent);
    }
  }
  ignoreSelectionEvents=false;
  selectedIndex=-1;
  valueChanged(null);
}
Program: 32867
Project: 32867
Buggy source:
/** 
 * Gets an event list that contains the current selection in this list table. That list changes dynamically as elements are selected and deselected from the list.
 */
public EventList getSelectionList(){
  return selectionList;
}

Fixed version (ground truth):
/** 
 * Gets an event list that contains the current selection in this list table. That list changes dynamically as elements are selected and deselected from the list. Because the list is dynamic, users should be careful of changes when accessing the SelectionList. It is safer to access the  SelectionList on the Swing event dispatch thread because no selection changes can occur while that thread is executing code.  It is still possible for changes to occur if the base list is being modified on another thread.
 */
public EventList getSelectionList(){
  return selectionList;
}
Program: 32868
Project: 32868
Buggy source:
/** 
 * Sets the table to use the appropriate comparator for this column
 * @todo the setHeaderValue method won't work permanently due to the factthat the TableFormat class overrides its value. Work out a way to set the value directly on the TableFormat?
 */
public void chooseComparator(int column,boolean ascending){
  Comparator selected;
  String sortedHeader=listTable.getTableFormat().getFieldName(column);
  if (comparators[column].size() > 0) {
    int comparatorIndex=columnClicks[column] % comparators[column].size();
    sortedHeader=sortedHeader + "String_Node_Str" + comparatorNames[column].get(comparatorIndex);
    selected=(Comparator)comparators[column].get(comparatorIndex);
  }
 else {
    selected=new ComparableComparator();
  }
  if (!ascending)   selected=new ReverseComparator(selected);
  sortedList.setComparator(selected);
  for (int c=0; c < table.getColumnCount(); c++) {
    if (c == column) {
      table.getColumnModel().getColumn(column).setHeaderValue(sortedHeader);
    }
 else {
      String header=listTable.getTableFormat().getFieldName(c);
      table.getColumnModel().getColumn(c).setHeaderValue(header);
    }
  }
  table.getTableHeader().revalidate();
  table.getTableHeader().repaint();
}

Fixed version (ground truth):
/** 
 * Sets the table to use the appropriate comparator for this column
 * @todo the setHeaderValue method won't work permanently due to the factthat the TableFormat class overrides its value. Work out a way to set the value directly on the TableFormat?
 * @param column the column-model column to choose a comparator for. This isdifferent from the view column which is the natural column in the table.
 */
public void chooseComparator(int column,boolean ascending){
  Comparator selected;
  String sortedHeader=listTable.getTableFormat().getFieldName(column);
  if (comparators[column].size() > 0) {
    int comparatorIndex=columnClicks[column] % comparators[column].size();
    sortedHeader=sortedHeader + "String_Node_Str" + comparatorNames[column].get(comparatorIndex);
    selected=(Comparator)comparators[column].get(comparatorIndex);
  }
 else {
    selected=new ComparableComparator();
  }
  if (!ascending)   selected=new ReverseComparator(selected);
  sortedList.setComparator(selected);
  for (int c=0; c < table.getColumnCount(); c++) {
    int modelColumn=table.convertColumnIndexToModel(c);
    if (modelColumn == column) {
      table.getColumnModel().getColumn(c).setHeaderValue(sortedHeader);
    }
 else {
      String header=listTable.getTableFormat().getFieldName(modelColumn);
      table.getColumnModel().getColumn(c).setHeaderValue(header);
    }
  }
  table.getTableHeader().revalidate();
  table.getTableHeader().repaint();
}
Program: 32869
Project: 32869
Buggy source:
/** 
 * AVL-Rotates this subtree with its left child. For every link (left, right, parent), there are up to three updates to be made. We need to set the new value on the replacement, the new value on this, and the new value on the other node.
 */
private void rotateLeft(){
  if (left == null)   throw new IllegalArgumentException("String_Node_Str");
  IndexedTreeNode replacement=left;
  left=replacement.right;
  leftSize=replacement.rightSize;
  if (replacement.right != null)   replacement.right.parent=this;
  if (parent != null) {
    parent.replaceChildNode(this,replacement);
  }
 else {
    host.setRootNode(replacement);
  }
  replacement.parent=parent;
  parent=replacement;
  replacement.right=this;
  replacement.rightSize=size();
}

Fixed version (ground truth):
/** 
 * AVL-Rotates this subtree with its left child. For every link (left, right, parent), there are up to three updates to be made. We need to set the new value on the replacement, the new value on this, and the new value on the other node.
 */
private void rotateLeft(){
  if (left == null)   throw new IllegalArgumentException("String_Node_Str");
  IndexedTreeNode replacement=left;
  left=replacement.right;
  leftSize=replacement.rightSize;
  if (replacement.right != null)   replacement.right.parent=this;
  if (parent != null) {
    parent.replaceChildNode(this,replacement);
  }
 else {
    host.setRootNode(replacement);
  }
  replacement.parent=parent;
  parent=replacement;
  replacement.right=this;
  replacement.rightSize=size();
  recalculateHeight();
  if (replacement.parent != null)   replacement.parent.recalculateHeight();
}
Program: 32870
Project: 32870
Buggy source:
/** 
 * Inserts the specified object into the tree with the specified index.
 * @return the SortedTreeNode node where the object was inserted. Thisnode can be used to call the deleteUp() method, which will delete the node from it's parent tree. It is also possible to call the getIndex() method on the node. As new nodes are inserted, the index will shift. The getIndex() method can be used to get the current index of the node at any time.
 */
public IndexedTreeNode insert(int index,Object inserted){
  if (index > leftSize + rootSize + rightSize)   throw new IndexOutOfBoundsException("String_Node_Str" + (leftSize + rootSize + rightSize) + "String_Node_Str"+ index);
  if (inserted == null)   throw new NullPointerException("String_Node_Str");
  if (index == 0 && value == null) {
    if (leftSize > 0 || rightSize > 0)     throw new IllegalStateException("String_Node_Str");
    rootSize++;
    value=inserted;
    return this;
  }
 else   if (index <= leftSize) {
    if (left == null)     left=new IndexedTreeNode(host,this);
    leftSize++;
    IndexedTreeNode result=left.insert(index,inserted);
    doRotationsForThisLevel();
    return result;
  }
 else {
    if (right == null)     right=new IndexedTreeNode(host,this);
    rightSize++;
    IndexedTreeNode result=right.insert(index - leftSize - rootSize,inserted);
    doRotationsForThisLevel();
    return result;
  }
}

Fixed version (ground truth):
/** 
 * Inserts the specified object into the tree with the specified index.
 * @return the SortedTreeNode node where the object was inserted. Thisnode can be used to call the deleteUp() method, which will delete the node from it's parent tree. It is also possible to call the getIndex() method on the node. As new nodes are inserted, the index will shift. The getIndex() method can be used to get the current index of the node at any time.
 */
public IndexedTreeNode insert(int index,Object inserted){
  if (index > leftSize + rootSize + rightSize)   throw new IndexOutOfBoundsException("String_Node_Str" + (leftSize + rootSize + rightSize) + "String_Node_Str"+ index);
  if (inserted == null)   throw new NullPointerException("String_Node_Str");
  if (index == 0 && value == null) {
    if (leftSize > 0 || rightSize > 0)     throw new IllegalStateException("String_Node_Str");
    rootSize++;
    value=inserted;
    recalculateHeight();
    return this;
  }
 else   if (index <= leftSize) {
    if (left == null)     left=new IndexedTreeNode(host,this);
    leftSize++;
    IndexedTreeNode result=left.insert(index,inserted);
    doRotationsForThisLevel();
    return result;
  }
 else {
    if (right == null)     right=new IndexedTreeNode(host,this);
    rightSize++;
    IndexedTreeNode result=right.insert(index - leftSize - rootSize,inserted);
    doRotationsForThisLevel();
    return result;
  }
}
Program: 32872
Project: 32872
Buggy source:
/** 
 * Retrieves the height of this subtree.
 */
private int height(){
  if (left == null && right == null)   return 1;
 else   if (right == null)   return 1 + left.height();
 else   if (left == null)   return 1 + right.height();
 else   return 1 + Math.max(left.height(),right.height());
}

Fixed version (ground truth):
/** 
 * Retrieves the height of this subtree.
 */
private int height(){
  return height;
}
Program: 32873
Project: 32873
Buggy source:
/** 
 * A primitive way to validate that nodes are stored in sorted order and that their sizes are consistent. This throws a IllegalStateException if any infraction is found.
 */
public void validate(){
  if (host.getComparator() != null) {
    if (leftSize > 0 && rootSize > 0 && host.getComparator().compare(left.value,value) > 0) {
      throw new IllegalStateException("String_Node_Str" + this + "String_Node_Str");
    }
    if (rightSize > 0 && rootSize > 0)     if (host.getComparator().compare(value,right.value) > 0) {
      throw new IllegalStateException("String_Node_Str" + this + "String_Node_Str");
    }
  }
  if ((left == null && leftSize != 0) || (left != null && leftSize != left.size())) {
    throw new IllegalStateException("String_Node_Str" + leftSize + "String_Node_Str"+ left.size());
  }
  if ((right == null && rightSize != 0) || (right != null && rightSize != right.size())) {
    throw new IllegalStateException("String_Node_Str" + rightSize + "String_Node_Str"+ right.size());
  }
}

Fixed version (ground truth):
/** 
 * A primitive way to validate that nodes are stored in sorted order and that their sizes are consistent. This throws a IllegalStateException if any infraction is found.
 */
public void validate(){
  if (left != null)   left.validate();
  if (right != null)   right.validate();
  if (host.getComparator() != null) {
    if (leftSize > 0 && rootSize > 0 && host.getComparator().compare(left.value,value) > 0) {
      throw new IllegalStateException("String_Node_Str" + this + "String_Node_Str");
    }
    if (rightSize > 0 && rootSize > 0)     if (host.getComparator().compare(value,right.value) > 0) {
      throw new IllegalStateException("String_Node_Str" + this + "String_Node_Str");
    }
  }
  if ((left == null && leftSize != 0) || (left != null && leftSize != left.size())) {
    throw new IllegalStateException("String_Node_Str" + leftSize + "String_Node_Str"+ left.size());
  }
  if ((right == null && rightSize != 0) || (right != null && rightSize != right.size())) {
    throw new IllegalStateException("String_Node_Str" + rightSize + "String_Node_Str"+ right.size());
  }
}
Program: 32874
Project: 32874
Buggy source:
/** 
 * AVL-Rotates this subtree with its right child. For every link (left, right, parent), there are up to three updates to be made. We need to set the new value on the replacement, the new value on this, and the new value on the other node.
 */
private void rotateRight(){
  if (right == null)   throw new IllegalArgumentException("String_Node_Str");
  IndexedTreeNode replacement=right;
  right=replacement.left;
  rightSize=replacement.leftSize;
  if (replacement.left != null)   replacement.left.parent=this;
  if (parent != null) {
    parent.replaceChildNode(this,replacement);
  }
 else {
    host.setRootNode(replacement);
  }
  replacement.parent=parent;
  parent=replacement;
  replacement.left=this;
  replacement.leftSize=size();
}

Fixed version (ground truth):
/** 
 * AVL-Rotates this subtree with its right child. For every link (left, right, parent), there are up to three updates to be made. We need to set the new value on the replacement, the new value on this, and the new value on the other node.
 */
private void rotateRight(){
  if (right == null)   throw new IllegalArgumentException("String_Node_Str");
  IndexedTreeNode replacement=right;
  right=replacement.left;
  rightSize=replacement.leftSize;
  if (replacement.left != null)   replacement.left.parent=this;
  if (parent != null) {
    parent.replaceChildNode(this,replacement);
  }
 else {
    host.setRootNode(replacement);
  }
  replacement.parent=parent;
  parent=replacement;
  replacement.left=this;
  replacement.leftSize=size();
  recalculateHeight();
  if (replacement.parent != null)   replacement.parent.recalculateHeight();
}
Program: 32875
Project: 32875
Buggy source:
/** 
 * Prints the tree by its contents.
 */
public String toString(){
  String valueString="String_Node_Str" + height();
  if (left != null && right != null) {
    return "String_Node_Str" + left.toString() + "String_Node_Str"+ valueString+ "String_Node_Str"+ right.toString()+ "String_Node_Str";
  }
 else   if (left != null) {
    return "String_Node_Str" + left.toString() + "String_Node_Str"+ valueString+ "String_Node_Str";
  }
 else   if (right != null) {
    return "String_Node_Str" + valueString + "String_Node_Str"+ right.toString()+ "String_Node_Str";
  }
 else   if (value == null) {
    return "String_Node_Str";
  }
 else {
    return valueString;
  }
}

Fixed version (ground truth):
/** 
 * Prints the tree by its contents.
 */
public String toString(){
  String valueString=value.toString();
  if (left != null && right != null) {
    return "String_Node_Str" + left.toString() + "String_Node_Str"+ valueString+ "String_Node_Str"+ right.toString()+ "String_Node_Str";
  }
 else   if (left != null) {
    return "String_Node_Str" + left.toString() + "String_Node_Str"+ valueString+ "String_Node_Str";
  }
 else   if (right != null) {
    return "String_Node_Str" + valueString + "String_Node_Str"+ right.toString()+ "String_Node_Str";
  }
 else   if (value == null) {
    return "String_Node_Str";
  }
 else {
    return valueString;
  }
}
Program: 32876
Project: 32876
Buggy source:
/** 
 * Removes from the list the last element that was returned by next or previous (optional operation).
 */
public void remove(){
  if (lastIndex == -1)   throw new IllegalStateException("String_Node_Str");
  target.remove(lastIndex);
  lastIndex=-1;
}

Fixed version (ground truth):
/** 
 * Removes from the list the last element that was returned by next or previous (optional operation).
 */
public void remove(){
  if (lastIndex == -1)   throw new IllegalStateException("String_Node_Str");
  target.remove(lastIndex);
  if (lastIndex <= nextIndex)   nextIndex--;
  lastIndex=-1;
}
Program: 32877
Project: 32877
Buggy source:
/** 
 * Recompiles the filter regular expression patterns. When the user enters a regular expression that is not recognized, the error is silently ignored and no filters apply.
 */
private void updateFilterPattern(){
  try {
    String[] filterStrings=filterEdit.getText().toLowerCase().split("String_Node_Str");
    filters=new Matcher[filterStrings.length];
    for (int i=0; i < filterStrings.length; i++) {
      filters[i]=Pattern.compile(filterStrings[i],Pattern.CASE_INSENSITIVE).matcher("String_Node_Str");
    }
  }
 catch (  PatternSyntaxException e) {
    filters=new Matcher[0];
  }
}

Fixed version (ground truth):
/** 
 * Recompiles the filter regular expression patterns. When the user enters a regular expression that is not recognized, the error is silently ignored and no filters apply.
 */
private void updateFilterPattern(){
  try {
    String[] filterStrings=filterEdit.getText().toLowerCase().split("String_Node_Str");
    filters=new Matcher[filterStrings.length];
    for (int i=0; i < filterStrings.length; i++) {
      filters[i]=getMatcher(filterStrings[i]);
    }
  }
 catch (  PatternSyntaxException e) {
    filters=new Matcher[0];
  }
}
Program: 32878
Project: 32878
Buggy source:
/** 
 * Sets the query list to display the specified query. The list will not change immediately, instead it will only change when the specified query has loaded. As a woraround, consider setting the query to an empty query to clear the list and then to the desired query.
 * @param period the number if milliseconds before the query isre-executed to refresh the table.
 */
public synchronized void setQuery(Query query){
  if (queryTimerTask != null)   queryTimerTask.cancel();
  queryTimerTask=taskManager.scheduleTask(new QueryTask(query),repeatPeriod);
}

Fixed version (ground truth):
/** 
 * Sets the query list to display the specified query. The list will not change immediately, instead it will only change when the specified query has loaded. As a woraround, consider setting the query to an empty query to clear the list and then to the desired query.
 * @param period the number if milliseconds before the query isre-executed to refresh the table.
 */
public synchronized void setQuery(Query query){
  if (queryTimerTask != null)   queryTimerTask.cancel();
  this.query=query;
  queryTimerTask=taskManager.scheduleTask(new QueryTask(query),repeatPeriod);
}
Program: 32879
Project: 32879
Buggy source:
/** 
 * When there is a change in one of the progress tasks, this is called to notify the Progress Bar of the change.
 */
public synchronized void taskUpdated(TaskContext task){
  boolean busy=false;
  for (Iterator i=taskManager.getTaskContexts().iterator(); i.hasNext(); ) {
    TaskContext taskContext=(TaskContext)i.next();
    if (taskContext.isBusy() || taskContext.getProgress() < 1.0)     busy=true;
  }
  if (busy)   iconHost.setIcon(busyIcon);
 else   iconHost.setIcon(idleIcon);
}

Fixed version (ground truth):
/** 
 * When there is a change in one of the progress tasks, this is called to notify the Progress Bar of the change.
 */
public synchronized void taskUpdated(TaskContext task){
  boolean busy=false;
  for (Iterator i=taskManager.getTaskContexts().iterator(); i.hasNext(); ) {
    TaskContext taskContext=(TaskContext)i.next();
    if (taskContext.isTaskFinished())     continue;
    if (taskContext.isBusy() || taskContext.getProgress() < 1.0)     busy=true;
  }
  if (busy)   iconHost.setIcon(busyIcon);
 else   iconHost.setIcon(idleIcon);
}
Program: 32880
Project: 32880
Buggy source:
/** 
 * Sets the query list to display the specified query. The list will not change immediately, instead it will only change when the specified query has loaded. As a woraround, consider setting the query to an empty query to clear the list and then to the desired query.
 */
public synchronized void setQuery(Query query){
  queryTaskContext.cancelTask();
  queryTaskContext=taskManager.runTask(new QueryTask(query));
}

Fixed version (ground truth):
/** 
 * Sets the query list to display the specified query. The list will not change immediately, instead it will only change when the specified query has loaded. As a woraround, consider setting the query to an empty query to clear the list and then to the desired query.
 */
public synchronized void setQuery(Query query){
  if (queryTaskContext != null)   queryTaskContext.cancelTask();
  queryTaskContext=taskManager.runTask(new QueryTask(query));
}
Program: 32881
Project: 32881
Buggy source:
/** 
 * When this task is executed it sets it's context as busy and performs the query on its background thread. It then sets the query results and sets itself as completed.
 */
public int doTask() throws InterruptedException, Exception {
  taskContext.setBusy(true);
  SortedSet results=query.doQuery();
  if (Thread.interrupted())   throw new InterruptedException();
  setQueryResults(results);
  taskContext.setBusy(false);
  return Task.COMPLETE;
}

Fixed version (ground truth):
/** 
 * When this task is executed it sets it's context as busy and performs the query on its background thread. It then sets the query results and sets itself as completed.
 */
public int doTask(int callSequence) throws InterruptedException, Exception {
  taskContext.setBusy(true);
  SortedSet results=query.doQuery();
  if (Thread.interrupted())   throw new InterruptedException();
  setQueryResults(results);
  taskContext.setBusy(false);
  return Task.COMPLETE;
}
Program: 32883
Project: 32883
Buggy source:
/** 
 * Starts the task runner to execute the specified task on its thread. The task will be executed until complete or an error occurs. The task runner may not be asked to run any more tasks until this task is marked complete in the TaskManager.taskComplete() method.
 */
public synchronized void runTask(Task task,TaskContext taskContext){
  if (executeState != IDLE || currentTask != null)   throw new RuntimeException("String_Node_Str");
  currentTask=task;
  currentTaskContext=taskContext;
  executeState=EXECUTE_WORKER;
  System.out.println("String_Node_Str");
  workerThread.interrupt();
}

Fixed version (ground truth):
/** 
 * Starts the task runner to execute the specified task on its thread. The task will be executed until complete or an error occurs. The task runner may not be asked to run any more tasks until this task is marked complete in the TaskManager.taskComplete() method.
 */
public synchronized void runTask(Task task,TaskContext taskContext){
  if (executeState != IDLE || currentTask != null)   throw new RuntimeException("String_Node_Str");
  currentTask=task;
  currentTaskContext=taskContext;
  currentCallSequence=0;
  executeState=EXECUTE_WORKER;
  System.out.println("String_Node_Str");
  workerThread.interrupt();
}
Program: 32884
Project: 32884
Buggy source:
/** 
 * Executes the task on the current thread one time, and prepares the execute state for the next execution.
 */
private synchronized void doTaskOnce(){
  try {
    int taskResult=currentTask.doTask();
    if (taskResult == Task.COMPLETE) {
      TaskContext completedContext=currentTaskContext;
      executeState=IDLE;
      currentTask=null;
      currentTaskContext=null;
      completedContext.taskComplete();
    }
 else     if (taskResult == Task.REPEAT_ON_WORKER_THREAD) {
      executeState=EXECUTE_WORKER;
    }
 else     if (taskResult == Task.REPEAT_ON_EVENT_DISPATCH_THREAD) {
      executeState=EXECUTE_EVENT_DISPATCH;
    }
  }
 catch (  InterruptedException e) {
    TaskContext completedContext=currentTaskContext;
    executeState=IDLE;
    currentTask=null;
    currentTaskContext=null;
    completedContext.taskInterrupted(e);
  }
catch (  Exception e) {
    TaskContext completedContext=currentTaskContext;
    executeState=IDLE;
    currentTask=null;
    currentTaskContext=null;
    completedContext.taskFailed(e);
  }
}

Fixed version (ground truth):
/** 
 * Executes the task on the current thread one time, and prepares the execute state for the next execution.
 */
private synchronized void doTaskOnce(){
  try {
    int taskResult=currentTask.doTask(currentCallSequence);
    currentCallSequence++;
    if (taskResult == Task.COMPLETE) {
      TaskContext completedContext=currentTaskContext;
      executeState=IDLE;
      currentTask=null;
      currentTaskContext=null;
      completedContext.taskComplete();
    }
 else     if (taskResult == Task.REPEAT_ON_WORKER_THREAD) {
      executeState=EXECUTE_WORKER;
    }
 else     if (taskResult == Task.REPEAT_ON_EVENT_DISPATCH_THREAD) {
      executeState=EXECUTE_EVENT_DISPATCH;
    }
  }
 catch (  InterruptedException e) {
    TaskContext completedContext=currentTaskContext;
    executeState=IDLE;
    currentTask=null;
    currentTaskContext=null;
    completedContext.taskInterrupted(e);
  }
catch (  Exception e) {
    TaskContext completedContext=currentTaskContext;
    executeState=IDLE;
    currentTask=null;
    currentTaskContext=null;
    completedContext.taskFailed(e);
  }
}
Program: 32888
Project: 32888
Buggy source:
@Override public void changed(ChangeEvent event,Actor actor){
  JFileChooser chooser=new JFileChooser();
  chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  int ret=chooser.showOpenDialog(null);
  if (ret == JFileChooser.APPROVE_OPTION) {
    File f=chooser.getSelectedFile();
    textDirectory.setText(f.getAbsolutePath());
    prefs.putString("String_Node_Str",f.getAbsolutePath());
    prefs.flush();
  }
}

Fixed version (ground truth):
@Override public void changed(ChangeEvent event,Actor actor){
  Frame frame=new Frame();
  frame.setUndecorated(true);
  frame.setOpacity(0);
  frame.setLocationRelativeTo(null);
  frame.setVisible(true);
  frame.toFront();
  frame.setVisible(false);
  frame.dispose();
  JFileChooser chooser=new JFileChooser();
  chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  int ret=chooser.showOpenDialog(null);
  if (ret == JFileChooser.APPROVE_OPTION) {
    File f=chooser.getSelectedFile();
    textDirectory.setText(f.getAbsolutePath());
    prefs.putString("String_Node_Str",f.getAbsolutePath());
    prefs.flush();
  }
}
Program: 32889
Project: 32889
Buggy source:
/** 
 */
public SystemFonts(){
  String osName=System.getProperty("String_Node_Str");
  if (osName.equals("String_Node_Str")) {
    fontPaths.add("String_Node_Str");
    fontPaths.add("String_Node_Str");
  }
 else   if (osName.contains("String_Node_Str")) {
    fontPaths.add("String_Node_Str");
  }
 else {
    fontPaths.add("String_Node_Str");
    fontPaths.add("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 */
public SystemFonts(){
  String osName=System.getProperty("String_Node_Str");
  if (osName.equals("String_Node_Str")) {
    fontPaths.add("String_Node_Str");
    fontPaths.add("String_Node_Str");
  }
 else   if (osName.contains("String_Node_Str")) {
    fontPaths.add("String_Node_Str");
  }
 else {
    fontPaths.add("String_Node_Str");
    fontPaths.add("String_Node_Str");
    fontPaths.add("String_Node_Str");
  }
}
Program: 32890
Project: 32890
Buggy source:
public SkinManager(TextureManager textureManagerInstance,File skinCacheDirectory,MinecraftSessionService sessionService){
  this.textureManager=textureManagerInstance;
  this.skinCacheDir=skinCacheDirectory;
  this.sessionService=sessionService;
  this.skinCacheLoader=CacheBuilder.newBuilder().expireAfterAccess(15L,TimeUnit.SECONDS).<GameProfile,Map<Type,MinecraftProfileTexture>>build(new CacheLoader<GameProfile,Map<Type,MinecraftProfileTexture>>(){
    public Map<Type,MinecraftProfileTexture> load(    GameProfile p_load_1_) throws Exception {
      return Minecraft.getMinecraft().getSessionService().getTextures(p_load_1_,false);
    }
  }
);
  customskinloader.loader.MojangAPILoader.defaultSessionService=sessionService;
  customskinloader.utils.HttpTextureUtil.defaultCacheDir=skinCacheDirectory;
  customskinloader.utils.HttpTextureUtil.initDefaultCacheDir();
}

Fixed version (ground truth):
public SkinManager(TextureManager textureManagerInstance,File skinCacheDirectory,MinecraftSessionService sessionService){
  this.textureManager=textureManagerInstance;
  this.skinCacheDir=skinCacheDirectory;
  this.sessionService=sessionService;
  this.skinCacheLoader=CacheBuilder.newBuilder().expireAfterAccess(15L,TimeUnit.SECONDS).<GameProfile,Map<Type,MinecraftProfileTexture>>build(new CacheLoader<GameProfile,Map<Type,MinecraftProfileTexture>>(){
    public Map<Type,MinecraftProfileTexture> load(    GameProfile p_load_1_) throws Exception {
      return Minecraft.getMinecraft().getSessionService().getTextures(p_load_1_,false);
    }
  }
);
  customskinloader.loader.MojangAPILoader.defaultSessionService=sessionService;
  customskinloader.utils.HttpTextureUtil.defaultCacheDir=skinCacheDirectory;
}
Program: 32891
Project: 32891
Buggy source:
public SkinManager(TextureManager textureManagerInstance,File skinCacheDirectory,MinecraftSessionService sessionService){
  this.textureManager=textureManagerInstance;
  this.skinCacheDir=skinCacheDirectory;
  this.sessionService=sessionService;
  this.skinCacheLoader=CacheBuilder.newBuilder().expireAfterAccess(15L,TimeUnit.SECONDS).<GameProfile,Map<Type,MinecraftProfileTexture>>build(new CacheLoader<GameProfile,Map<Type,MinecraftProfileTexture>>(){
    public Map<Type,MinecraftProfileTexture> load(    GameProfile p_load_1_) throws Exception {
      return Minecraft.getMinecraft().getSessionService().getTextures(p_load_1_,false);
    }
  }
);
  customskinloader.loader.MojangAPILoader.defaultSessionService=sessionService;
  customskinloader.utils.HttpTextureUtil.defaultCacheDir=skinCacheDirectory;
  customskinloader.utils.HttpTextureUtil.initDefaultCacheDir();
}

Fixed version (ground truth):
public SkinManager(TextureManager textureManagerInstance,File skinCacheDirectory,MinecraftSessionService sessionService){
  this.textureManager=textureManagerInstance;
  this.skinCacheDir=skinCacheDirectory;
  this.sessionService=sessionService;
  this.skinCacheLoader=CacheBuilder.newBuilder().expireAfterAccess(15L,TimeUnit.SECONDS).<GameProfile,Map<Type,MinecraftProfileTexture>>build(new CacheLoader<GameProfile,Map<Type,MinecraftProfileTexture>>(){
    public Map<Type,MinecraftProfileTexture> load(    GameProfile p_load_1_) throws Exception {
      return Minecraft.getMinecraft().getSessionService().getTextures(p_load_1_,false);
    }
  }
);
  customskinloader.loader.MojangAPILoader.defaultSessionService=sessionService;
  customskinloader.utils.HttpTextureUtil.defaultCacheDir=skinCacheDirectory;
}
Program: 32892
Project: 32892
Buggy source:
public SkinManager(TextureManager textureManagerInstance,File skinCacheDirectory,MinecraftSessionService sessionService){
  this.textureManager=textureManagerInstance;
  this.skinCacheDir=skinCacheDirectory;
  this.sessionService=sessionService;
  this.skinCacheLoader=CacheBuilder.newBuilder().expireAfterAccess(15L,TimeUnit.SECONDS).build(new CacheLoader(){
    private static final String __OBFID="String_Node_Str";
    public Map func_152786_a(    GameProfile p_152786_1_){
      return Minecraft.getMinecraft().getSessionService().getTextures(p_152786_1_,false);
    }
    public Object load(    Object p_load_1_){
      return this.func_152786_a((GameProfile)p_load_1_);
    }
  }
);
  customskinloader.loader.MojangAPILoader.defaultSessionService=sessionService;
  customskinloader.utils.HttpTextureUtil.defaultCacheDir=skinCacheDirectory;
  customskinloader.utils.HttpTextureUtil.initDefaultCacheDir();
}

Fixed version (ground truth):
public SkinManager(TextureManager textureManagerInstance,File skinCacheDirectory,MinecraftSessionService sessionService){
  this.textureManager=textureManagerInstance;
  this.skinCacheDir=skinCacheDirectory;
  this.sessionService=sessionService;
  this.skinCacheLoader=CacheBuilder.newBuilder().expireAfterAccess(15L,TimeUnit.SECONDS).build(new CacheLoader(){
    private static final String __OBFID="String_Node_Str";
    public Map func_152786_a(    GameProfile p_152786_1_){
      return Minecraft.getMinecraft().getSessionService().getTextures(p_152786_1_,false);
    }
    public Object load(    Object p_load_1_){
      return this.func_152786_a((GameProfile)p_load_1_);
    }
  }
);
  customskinloader.loader.MojangAPILoader.defaultSessionService=sessionService;
  customskinloader.utils.HttpTextureUtil.defaultCacheDir=skinCacheDirectory;
}
Program: 32893
Project: 32893
Buggy source:
public SkinManager(TextureManager textureManagerInstance,File skinCacheDirectory,MinecraftSessionService sessionService){
  this.textureManager=textureManagerInstance;
  this.skinCacheDir=skinCacheDirectory;
  this.sessionService=sessionService;
  this.skinCacheLoader=CacheBuilder.newBuilder().expireAfterAccess(15L,TimeUnit.SECONDS).build(new CacheLoader(){
    private static final String __OBFID="String_Node_Str";
    public Map func_152786_a(    GameProfile profile){
      return Minecraft.getMinecraft().getSessionService().getTextures(profile,false);
    }
    public Object load(    Object p_load_1_){
      return this.func_152786_a((GameProfile)p_load_1_);
    }
  }
);
  customskinloader.loader.MojangAPILoader.defaultSessionService=sessionService;
  customskinloader.utils.HttpTextureUtil.defaultCacheDir=skinCacheDirectory;
  customskinloader.utils.HttpTextureUtil.initDefaultCacheDir();
}

Fixed version (ground truth):
public SkinManager(TextureManager textureManagerInstance,File skinCacheDirectory,MinecraftSessionService sessionService){
  this.textureManager=textureManagerInstance;
  this.skinCacheDir=skinCacheDirectory;
  this.sessionService=sessionService;
  this.skinCacheLoader=CacheBuilder.newBuilder().expireAfterAccess(15L,TimeUnit.SECONDS).build(new CacheLoader(){
    private static final String __OBFID="String_Node_Str";
    public Map func_152786_a(    GameProfile profile){
      return Minecraft.getMinecraft().getSessionService().getTextures(profile,false);
    }
    public Object load(    Object p_load_1_){
      return this.func_152786_a((GameProfile)p_load_1_);
    }
  }
);
  customskinloader.loader.MojangAPILoader.defaultSessionService=sessionService;
  customskinloader.utils.HttpTextureUtil.defaultCacheDir=skinCacheDirectory;
}
Program: 32894
Project: 32894
Buggy source:
public SkinManager(TextureManager textureManagerInstance,File skinCacheDirectory,MinecraftSessionService sessionService){
  this.textureManager=textureManagerInstance;
  this.skinCacheDir=skinCacheDirectory;
  this.sessionService=sessionService;
  this.skinCacheLoader=CacheBuilder.newBuilder().expireAfterAccess(15L,TimeUnit.SECONDS).<GameProfile,Map<Type,MinecraftProfileTexture>>build(new CacheLoader<GameProfile,Map<Type,MinecraftProfileTexture>>(){
    public Map<Type,MinecraftProfileTexture> load(    GameProfile p_load_1_) throws Exception {
      return Minecraft.getMinecraft().getSessionService().getTextures(p_load_1_,false);
    }
  }
);
  customskinloader.loader.MojangAPILoader.defaultSessionService=sessionService;
  customskinloader.utils.HttpTextureUtil.defaultCacheDir=skinCacheDirectory;
  customskinloader.utils.HttpTextureUtil.initDefaultCacheDir();
}

Fixed version (ground truth):
public SkinManager(TextureManager textureManagerInstance,File skinCacheDirectory,MinecraftSessionService sessionService){
  this.textureManager=textureManagerInstance;
  this.skinCacheDir=skinCacheDirectory;
  this.sessionService=sessionService;
  this.skinCacheLoader=CacheBuilder.newBuilder().expireAfterAccess(15L,TimeUnit.SECONDS).<GameProfile,Map<Type,MinecraftProfileTexture>>build(new CacheLoader<GameProfile,Map<Type,MinecraftProfileTexture>>(){
    public Map<Type,MinecraftProfileTexture> load(    GameProfile p_load_1_) throws Exception {
      return Minecraft.getMinecraft().getSessionService().getTextures(p_load_1_,false);
    }
  }
);
  customskinloader.loader.MojangAPILoader.defaultSessionService=sessionService;
  customskinloader.utils.HttpTextureUtil.defaultCacheDir=skinCacheDirectory;
}