nus-yam/ex-repair huggingface dataset:
Program: 32817
Project: 32817
Buggy source:
/** 
 * Index node pairs are compared first by their Object's values, and then by their indices.
 */
public int compareTo(Object other){
  IndexNodePair otherIndexNodePair=(IndexNodePair)other;
  Object myObject=source.get(node.getIndex());
  Object otherObject=source.get(otherIndexNodePair.node.getIndex());
  int compareResult=comparator.compare(myObject,otherObject);
  if (compareResult != 0)   return compareResult;
  return index - otherIndexNodePair.index;
}

Fixed version (ground truth):
/** 
 * Index node pairs are compared first by their Object's values, and then by their indices.
 */
public int compareTo(Object other){
  IndexNodePair otherIndexNodePair=(IndexNodePair)other;
  if (comparator != null) {
    Object myObject=source.get(node.getIndex());
    Object otherObject=source.get(otherIndexNodePair.node.getIndex());
    int compareResult=comparator.compare(myObject,otherObject);
    if (compareResult != 0)     return compareResult;
  }
  return index - otherIndexNodePair.index;
}
Program: 32818
Project: 32818
Buggy source:
/** 
 * Change the selection to be the set union of the current selection  and the indices between index0 and index1 inclusive
 */
public void addSelectionInterval(int index0,int index1){
  ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().lock();
  try {
    if (!enabled)     return;
    anchorSelectionIndex=index0;
    leadSelectionIndex=index1;
    if (selectionMode == SINGLE_SELECTION) {
      setSubRangeOfRange(true,index0,index0,getMinSelectionIndex(),getMaxSelectionIndex());
    }
 else     if (selectionMode == SINGLE_INTERVAL_SELECTION) {
      boolean overlap=false;
      int minSelectedIndex=getMinSelectionIndex();
      int maxSelectedIndex=getMaxSelectionIndex();
      if (minSelectedIndex - 1 <= index0 && index0 <= maxSelectedIndex + 1)       overlap=true;
      if (minSelectedIndex - 1 <= index1 && index1 <= maxSelectedIndex + 1)       overlap=true;
      if (overlap) {
        setSubRangeOfRange(true,index0,index1,-1,-1);
      }
 else {
        setSubRangeOfRange(true,index0,index1,minSelectedIndex,maxSelectedIndex);
      }
    }
 else {
      setSubRangeOfRange(true,index0,index1,-1,-1);
    }
  }
  finally {
    ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * Change the selection to be the set union of the current selection  and the indices between index0 and index1 inclusive
 */
public void addSelectionInterval(int index0,int index1){
  ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().lock();
  try {
    if (!enabled)     return;
    if (index0 < 0 || index1 < 0) {
      return;
    }
    anchorSelectionIndex=index0;
    leadSelectionIndex=index1;
    if (selectionMode == SINGLE_SELECTION) {
      setSubRangeOfRange(true,index0,index0,getMinSelectionIndex(),getMaxSelectionIndex());
    }
 else     if (selectionMode == SINGLE_INTERVAL_SELECTION) {
      boolean overlap=false;
      int minSelectedIndex=getMinSelectionIndex();
      int maxSelectedIndex=getMaxSelectionIndex();
      if (minSelectedIndex - 1 <= index0 && index0 <= maxSelectedIndex + 1)       overlap=true;
      if (minSelectedIndex - 1 <= index1 && index1 <= maxSelectedIndex + 1)       overlap=true;
      if (overlap) {
        setSubRangeOfRange(true,index0,index1,-1,-1);
      }
 else {
        setSubRangeOfRange(true,index0,index1,minSelectedIndex,maxSelectedIndex);
      }
    }
 else {
      setSubRangeOfRange(true,index0,index1,-1,-1);
    }
  }
  finally {
    ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().unlock();
  }
}
Program: 32820
Project: 32820
Buggy source:
/** 
 * Change the selection to be between index0 and index1 inclusive. First this calculates the smallest range where changes occur. This includes the union of the selection range before and the selection range specified. It then walks through the change and sets each index as selected or not based on whether the index is in the  new range. Finally it fires events to both the listening lists and selection listeners about what changes happened. If the selection does not change, this will not fire any events.
 */
public void setSelectionInterval(int index0,int index1){
  ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().lock();
  try {
    if (!enabled)     return;
    anchorSelectionIndex=index0;
    leadSelectionIndex=index1;
    if (selectionMode == SINGLE_SELECTION) {
      setSubRangeOfRange(true,index0,index0,getMinSelectionIndex(),getMaxSelectionIndex());
    }
 else {
      setSubRangeOfRange(true,index0,index1,getMinSelectionIndex(),getMaxSelectionIndex());
    }
  }
  finally {
    ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * Change the selection to be between index0 and index1 inclusive. <p>First this calculates the smallest range where changes occur. This includes the union of the selection range before and the selection range specified. It then walks through the change and sets each index as selected or not based on whether the index is in the  new range. Finally it fires events to both the listening lists and selection listeners about what changes happened. <p>If the selection does not change, this will not fire any events.
 */
public void setSelectionInterval(int index0,int index1){
  ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().lock();
  try {
    if (!enabled)     return;
    if (index0 < 0 || index1 < 0) {
      clearSelection();
      return;
    }
    anchorSelectionIndex=index0;
    leadSelectionIndex=index1;
    if (selectionMode == SINGLE_SELECTION) {
      setSubRangeOfRange(true,index0,index0,getMinSelectionIndex(),getMaxSelectionIndex());
    }
 else {
      setSubRangeOfRange(true,index0,index1,getMinSelectionIndex(),getMaxSelectionIndex());
    }
  }
  finally {
    ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().unlock();
  }
}
Program: 32821
Project: 32821
Buggy source:
/** 
 * Change the selection to be the set difference of the current selection  and the indices between index0 and index1 inclusive.
 */
public void removeSelectionInterval(int index0,int index1){
  ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().lock();
  try {
    if (!enabled)     return;
    anchorSelectionIndex=index0;
    leadSelectionIndex=index1;
    if (selectionMode == SINGLE_SELECTION) {
      setSubRangeOfRange(false,getMinSelectionIndex(),getMaxSelectionIndex(),-1,-1);
    }
 else     if (selectionMode == SINGLE_INTERVAL_SELECTION) {
      setSubRangeOfRange(false,index0,getMaxSelectionIndex(),-1,-1);
    }
 else {
      setSubRangeOfRange(false,index0,index1,-1,-1);
    }
  }
  finally {
    ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * Change the selection to be the set difference of the current selection  and the indices between index0 and index1 inclusive.
 */
public void removeSelectionInterval(int index0,int index1){
  ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().lock();
  try {
    if (!enabled)     return;
    if (index0 < 0 || index1 < 0) {
      return;
    }
    anchorSelectionIndex=index0;
    leadSelectionIndex=index1;
    if (selectionMode == SINGLE_SELECTION) {
      setSubRangeOfRange(false,getMinSelectionIndex(),getMaxSelectionIndex(),-1,-1);
    }
 else     if (selectionMode == SINGLE_INTERVAL_SELECTION) {
      setSubRangeOfRange(false,index0,getMaxSelectionIndex(),-1,-1);
    }
 else {
      setSubRangeOfRange(false,index0,index1,-1,-1);
    }
  }
  finally {
    ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().unlock();
  }
}
Program: 32822
Project: 32822
Buggy source:
/** 
 * Returns the number of elements in this list. This is the number of elements currently selected.
 */
public int size(){
  return flagList.getCompressedList().size();
}

Fixed version (ground truth):
/** 
 * Returns the number of elements in this list.
 * @return the number of elements currently selected.
 */
public int size(){
  return flagList.getCompressedList().size();
}
Program: 32823
Project: 32823
Buggy source:
/** 
 * Gets the index of the node with the specified compressedIndex. Compressed index is defined as the index of that element in the compressed list. This is the index of the node if all nulls were to be removed from the list.
 */
public int getIndex(int compressedIndex){
  if (root == null)   throw new IndexOutOfBoundsException("String_Node_Str" + compressedIndex);
  SparseListNode node=root.getNodeByCompressedIndex(compressedIndex);
  return node.getIndex();
}

Fixed version (ground truth):
/** 
 * Gets the index of the node with the specified compressedIndex. Compressed index is defined as the index of that element in the compressed list. This is the index of the node if all nulls were to be removed from the list.
 */
public int getIndex(int compressedIndex){
  if (root == null)   throw new IndexOutOfBoundsException("String_Node_Str" + compressedIndex);
  return root.getIndexByCompressedIndex(compressedIndex);
}
Program: 32824
Project: 32824
Buggy source:
/** 
 * Gets the sorting style for this column.
 */
public int getSortingStyle(){
  if (clickCount == 0)   return COLUMN_UNSORTED;
  if (column == primaryColumn) {
    if (isReverse()) {
      if (getComparatorIndex() == 0)       return COLUMN_PRIMARY_SORTED;
 else       return COLUMN_PRIMARY_SORTED_ALTERNATE;
    }
 else {
      if (getComparatorIndex() == 0)       return COLUMN_PRIMARY_SORTED_REVERSE;
 else       return COLUMN_PRIMARY_SORTED_ALTERNATE_REVERSE;
    }
  }
 else {
    if (isReverse()) {
      if (getComparatorIndex() == 0)       return COLUMN_SECONDARY_SORTED;
 else       return COLUMN_SECONDARY_SORTED_ALTERNATE;
    }
 else {
      if (getComparatorIndex() == 0)       return COLUMN_SECONDARY_SORTED_REVERSE;
 else       return COLUMN_SECONDARY_SORTED_ALTERNATE_REVERSE;
    }
  }
}

Fixed version (ground truth):
/** 
 * Gets the sorting style for this column.
 */
public int getSortingStyle(){
  if (clickCount == 0)   return COLUMN_UNSORTED;
  if (column == primaryColumn) {
    if (!isReverse()) {
      if (getComparatorIndex() == 0)       return COLUMN_PRIMARY_SORTED;
 else       return COLUMN_PRIMARY_SORTED_ALTERNATE;
    }
 else {
      if (getComparatorIndex() == 0)       return COLUMN_PRIMARY_SORTED_REVERSE;
 else       return COLUMN_PRIMARY_SORTED_ALTERNATE_REVERSE;
    }
  }
 else {
    if (!isReverse()) {
      if (getComparatorIndex() == 0)       return COLUMN_SECONDARY_SORTED;
 else       return COLUMN_SECONDARY_SORTED_ALTERNATE;
    }
 else {
      if (getComparatorIndex() == 0)       return COLUMN_SECONDARY_SORTED_REVERSE;
 else       return COLUMN_SECONDARY_SORTED_ALTERNATE_REVERSE;
    }
  }
}
Program: 32826
Project: 32826
Buggy source:
public int compare(Object a,Object b){
  int number1=((Integer)a).intValue();
  int number2=((Integer)b).intValue();
  int number1Flipped=flip(number1);
  int number2Flipped=flip(number2);
  return number1Flipped - number2Flipped;
}

Fixed version (ground truth):
public int compare(Object a,Object b){
  String aString=(String)a;
  String bString=(String)b;
  return delegate.compare(flip(aString),flip(bString));
}
Program: 32829
Project: 32829
Buggy source:
/** 
 * Create a filter list that filters the specified source list, which must contain only Issue objects.
 */
public IssuesUserFilter(EventList source){
  super(source);
  source.addListEventListener(new ConsistencyTestList(source,"String_Node_Str",true));
  SortedList sortedSource=new SortedList(new IssuesToUserList(source));
  sortedSource.addListEventListener(new ConsistencyTestList(sortedSource,"String_Node_Str",true));
  usersEventList=new UniqueList(new IssuesToUserList(source));
  usersEventList.addListEventListener(new ConsistencyTestList(usersEventList,"String_Node_Str",true));
  EventListModel usersListModel=new EventListModel(usersEventList);
  userSelect=new JList(usersListModel);
  EventSelectionModel userSelectionModel=new EventSelectionModel(usersEventList);
  userSelect.setSelectionModel(userSelectionModel.getListSelectionModel());
  usersSelectedList=userSelectionModel.getEventList();
  userSelect.addListSelectionListener(this);
  handleFilterChanged();
}

Fixed version (ground truth):
/** 
 * Create a filter list that filters the specified source list, which must contain only Issue objects.
 */
public IssuesUserFilter(EventList source){
  super(source);
  usersEventList=new UniqueList(new IssuesToUserList(source));
  EventListModel usersListModel=new EventListModel(usersEventList);
  userSelect=new JList(usersListModel);
  EventSelectionModel userSelectionModel=new EventSelectionModel(usersEventList);
  userSelect.setSelectionModel(userSelectionModel.getListSelectionModel());
  usersSelectedList=userSelectionModel.getEventList();
  userSelect.addListSelectionListener(this);
  handleFilterChanged();
  this.addListEventListener(new ConsistencyTestList(this,"String_Node_Str",true));
  source.addListEventListener(new ConsistencyTestList(source,"String_Node_Str",true));
}
Program: 32831
Project: 32831
Buggy source:
/** 
 * Change the selection to be the set union of the current selection  and the indices between index0 and index1 inclusive
 */
public void addSelectionInterval(int index0,int index1){
  ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().lock();
  try {
    anchorSelectionIndex=index0;
    leadSelectionIndex=index1;
    if (selectionMode == SINGLE_SELECTION) {
      setSubRangeOfRange(true,index0,index0,getMinSelectionIndex(),getMaxSelectionIndex());
    }
 else     if (selectionMode == SINGLE_INTERVAL_SELECTION) {
      boolean overlap=false;
      int minSelectedIndex=getMinSelectionIndex();
      int maxSelectedIndex=getMaxSelectionIndex();
      if (minSelectedIndex - 1 <= index0 && index0 <= maxSelectedIndex + 1)       overlap=true;
      if (minSelectedIndex - 1 <= index1 && index1 <= maxSelectedIndex + 1)       overlap=true;
      if (overlap) {
        setSubRangeOfRange(true,index0,index1,-1,-1);
      }
 else {
        setSubRangeOfRange(true,index0,index1,minSelectedIndex,maxSelectedIndex);
      }
    }
 else {
      setSubRangeOfRange(true,index0,index1,-1,-1);
    }
  }
  finally {
    ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * Change the selection to be the set union of the current selection  and the indices between index0 and index1 inclusive
 */
public void addSelectionInterval(int index0,int index1){
  ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().lock();
  try {
    if (!enabled)     return;
    anchorSelectionIndex=index0;
    leadSelectionIndex=index1;
    if (selectionMode == SINGLE_SELECTION) {
      setSubRangeOfRange(true,index0,index0,getMinSelectionIndex(),getMaxSelectionIndex());
    }
 else     if (selectionMode == SINGLE_INTERVAL_SELECTION) {
      boolean overlap=false;
      int minSelectedIndex=getMinSelectionIndex();
      int maxSelectedIndex=getMaxSelectionIndex();
      if (minSelectedIndex - 1 <= index0 && index0 <= maxSelectedIndex + 1)       overlap=true;
      if (minSelectedIndex - 1 <= index1 && index1 <= maxSelectedIndex + 1)       overlap=true;
      if (overlap) {
        setSubRangeOfRange(true,index0,index1,-1,-1);
      }
 else {
        setSubRangeOfRange(true,index0,index1,minSelectedIndex,maxSelectedIndex);
      }
    }
 else {
      setSubRangeOfRange(true,index0,index1,-1,-1);
    }
  }
  finally {
    ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().unlock();
  }
}
Program: 32832
Project: 32832
Buggy source:
/** 
 * Change the selection to the empty set.
 */
public void clearSelection(){
  ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().lock();
  try {
    setSubRangeOfRange(false,getMinSelectionIndex(),getMaxSelectionIndex(),-1,-1);
  }
  finally {
    ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * Change the selection to the empty set.
 */
public void clearSelection(){
  ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().lock();
  try {
    if (!enabled)     return;
    setSubRangeOfRange(false,getMinSelectionIndex(),getMaxSelectionIndex(),-1,-1);
  }
  finally {
    ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().unlock();
  }
}
Program: 32833
Project: 32833
Buggy source:
/** 
 * Change the selection to be between index0 and index1 inclusive. First this calculates the smallest range where changes occur. This includes the union of the selection range before and the selection range specified. It then walks through the change and sets each index as selected or not based on whether the index is in the  new range. Finally it fires events to both the listening lists and selection listeners about what changes happened. If the selection does not change, this will not fire any events.
 */
public void setSelectionInterval(int index0,int index1){
  ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().lock();
  try {
    anchorSelectionIndex=index0;
    leadSelectionIndex=index1;
    if (selectionMode == SINGLE_SELECTION) {
      setSubRangeOfRange(true,index0,index0,getMinSelectionIndex(),getMaxSelectionIndex());
    }
 else {
      setSubRangeOfRange(true,index0,index1,getMinSelectionIndex(),getMaxSelectionIndex());
    }
  }
  finally {
    ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * Change the selection to be between index0 and index1 inclusive. First this calculates the smallest range where changes occur. This includes the union of the selection range before and the selection range specified. It then walks through the change and sets each index as selected or not based on whether the index is in the  new range. Finally it fires events to both the listening lists and selection listeners about what changes happened. If the selection does not change, this will not fire any events.
 */
public void setSelectionInterval(int index0,int index1){
  ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().lock();
  try {
    if (!enabled)     return;
    anchorSelectionIndex=index0;
    leadSelectionIndex=index1;
    if (selectionMode == SINGLE_SELECTION) {
      setSubRangeOfRange(true,index0,index0,getMinSelectionIndex(),getMaxSelectionIndex());
    }
 else {
      setSubRangeOfRange(true,index0,index1,getMinSelectionIndex(),getMaxSelectionIndex());
    }
  }
  finally {
    ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().unlock();
  }
}
Program: 32834
Project: 32834
Buggy source:
/** 
 * Set the anchor selection index.
 */
public void setAnchorSelectionIndex(int anchorSelectionIndex){
  ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().lock();
  try {
    this.anchorSelectionIndex=anchorSelectionIndex;
    if (anchorSelectionIndex == -1) {
      clearSelection();
      return;
    }
    if (selectionMode == SINGLE_SELECTION) {
      setSubRangeOfRange(true,anchorSelectionIndex,anchorSelectionIndex,getMinSelectionIndex(),getMaxSelectionIndex());
    }
 else     if (selectionMode == SINGLE_INTERVAL_SELECTION) {
      setSubRangeOfRange(true,anchorSelectionIndex,leadSelectionIndex,getMinSelectionIndex(),getMaxSelectionIndex());
    }
 else {
      setSubRangeOfRange(true,anchorSelectionIndex,leadSelectionIndex,-1,-1);
    }
  }
  finally {
    ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * Set the anchor selection index.
 */
public void setAnchorSelectionIndex(int anchorSelectionIndex){
  ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().lock();
  try {
    if (!enabled)     return;
    this.anchorSelectionIndex=anchorSelectionIndex;
    if (anchorSelectionIndex == -1) {
      clearSelection();
      return;
    }
    if (selectionMode == SINGLE_SELECTION) {
      setSubRangeOfRange(true,anchorSelectionIndex,anchorSelectionIndex,getMinSelectionIndex(),getMaxSelectionIndex());
    }
 else     if (selectionMode == SINGLE_INTERVAL_SELECTION) {
      setSubRangeOfRange(true,anchorSelectionIndex,leadSelectionIndex,getMinSelectionIndex(),getMaxSelectionIndex());
    }
 else {
      setSubRangeOfRange(true,anchorSelectionIndex,leadSelectionIndex,-1,-1);
    }
  }
  finally {
    ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().unlock();
  }
}
Program: 32835
Project: 32835
Buggy source:
/** 
 * Change the selection to be the set difference of the current selection  and the indices between index0 and index1 inclusive.
 */
public void removeSelectionInterval(int index0,int index1){
  ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().lock();
  try {
    anchorSelectionIndex=index0;
    leadSelectionIndex=index1;
    if (selectionMode == SINGLE_SELECTION) {
      setSubRangeOfRange(false,getMinSelectionIndex(),getMaxSelectionIndex(),-1,-1);
    }
 else     if (selectionMode == SINGLE_INTERVAL_SELECTION) {
      setSubRangeOfRange(false,index0,getMaxSelectionIndex(),-1,-1);
    }
 else {
      setSubRangeOfRange(false,index0,index1,-1,-1);
    }
  }
  finally {
    ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * Change the selection to be the set difference of the current selection  and the indices between index0 and index1 inclusive.
 */
public void removeSelectionInterval(int index0,int index1){
  ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().lock();
  try {
    if (!enabled)     return;
    anchorSelectionIndex=index0;
    leadSelectionIndex=index1;
    if (selectionMode == SINGLE_SELECTION) {
      setSubRangeOfRange(false,getMinSelectionIndex(),getMaxSelectionIndex(),-1,-1);
    }
 else     if (selectionMode == SINGLE_INTERVAL_SELECTION) {
      setSubRangeOfRange(false,index0,getMaxSelectionIndex(),-1,-1);
    }
 else {
      setSubRangeOfRange(false,index0,index1,-1,-1);
    }
  }
  finally {
    ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().unlock();
  }
}
Program: 32836
Project: 32836
Buggy source:
/** 
 * Set the lead selection index.
 */
public void setLeadSelectionIndex(int leadSelectionIndex){
  ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().lock();
  try {
    int originalLeadIndex=this.leadSelectionIndex;
    this.leadSelectionIndex=leadSelectionIndex;
    if (leadSelectionIndex == -1) {
      clearSelection();
      return;
    }
    if (selectionMode == SINGLE_SELECTION) {
      setSubRangeOfRange(true,leadSelectionIndex,leadSelectionIndex,getMinSelectionIndex(),getMaxSelectionIndex());
    }
 else     if (selectionMode == SINGLE_INTERVAL_SELECTION) {
      setSubRangeOfRange(true,anchorSelectionIndex,leadSelectionIndex,getMinSelectionIndex(),getMaxSelectionIndex());
    }
 else {
      setSubRangeOfRange(true,anchorSelectionIndex,leadSelectionIndex,anchorSelectionIndex,originalLeadIndex);
    }
  }
  finally {
    ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * Set the lead selection index.
 */
public void setLeadSelectionIndex(int leadSelectionIndex){
  ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().lock();
  try {
    if (!enabled)     return;
    int originalLeadIndex=this.leadSelectionIndex;
    this.leadSelectionIndex=leadSelectionIndex;
    if (leadSelectionIndex == -1) {
      clearSelection();
      return;
    }
    if (selectionMode == SINGLE_SELECTION) {
      setSubRangeOfRange(true,leadSelectionIndex,leadSelectionIndex,getMinSelectionIndex(),getMaxSelectionIndex());
    }
 else     if (selectionMode == SINGLE_INTERVAL_SELECTION) {
      setSubRangeOfRange(true,anchorSelectionIndex,leadSelectionIndex,getMinSelectionIndex(),getMaxSelectionIndex());
    }
 else {
      setSubRangeOfRange(true,anchorSelectionIndex,leadSelectionIndex,anchorSelectionIndex,originalLeadIndex);
    }
  }
  finally {
    ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().unlock();
  }
}
Program: 32837
Project: 32837
Buggy source:
/** 
 * Creates a new TableComparatorChooser that responds to clicks on the specified table and uses them to sort the specified list.
 * @param table the table with headers that can be clicked on.
 * @param sortedList the sorted list to update.
 * @param multipleColumnSort true to sort by multiple columns at a time, ortrue to sort by a single column. Although sorting by multiple columns is more powerful, the user interface is not as simple and this strategy should only be used where necessary.
 */
public TableComparatorChooser(JTable table,SortedList sortedList,boolean multipleColumnSort){
  this.table=table;
  this.sortedList=sortedList;
  this.multipleColumnSort=multipleColumnSort;
  try {
    eventTableModel=(EventTableModel)table.getModel();
  }
 catch (  ClassCastException e) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  rebuildColumns();
  table.getTableHeader().setDefaultRenderer(new SortArrowHeaderRenderer());
  table.setColumnSelectionAllowed(false);
  table.getTableHeader().addMouseListener(this);
  table.getModel().addTableModelListener(this);
}

Fixed version (ground truth):
/** 
 * Creates a new TableComparatorChooser that responds to clicks on the specified table and uses them to sort the specified list.
 * @param table the table with headers that can be clicked on.
 * @param sortedList the sorted list to update.
 * @param multipleColumnSort <code>true</code> to sort by multiple columnsat a time, or <code>false</code> to sort by a single column. Although sorting by multiple columns is more powerful, the user interface is not as simple and this strategy should only be used where necessary.
 */
public TableComparatorChooser(JTable table,SortedList sortedList,boolean multipleColumnSort){
  this.table=table;
  this.sortedList=sortedList;
  this.multipleColumnSort=multipleColumnSort;
  try {
    eventTableModel=(EventTableModel)table.getModel();
  }
 catch (  ClassCastException e) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  rebuildColumns();
  table.getTableHeader().setDefaultRenderer(new SortArrowHeaderRenderer());
  table.setColumnSelectionAllowed(false);
  table.getTableHeader().addMouseListener(this);
  table.getModel().addTableModelListener(this);
}
Program: 32840
Project: 32840
Buggy source:
/** 
 * Creates a new ConsistencyTestList that ensures events from the source list are consistent.
 */
public ConsistencyTestList(EventList source,String name){
  this.source=source;
  this.name=name;
  size=source.size();
}

Fixed version (ground truth):
/** 
 * Creates a new ConsistencyTestList that ensures events from the source list are consistent.
 */
public ConsistencyTestList(EventList source,String name){
  this(source,name,false);
}
Program: 32841
Project: 32841
Buggy source:
/** 
 * Create a filter list that filters the specified source list, which must contain only Issue objects.
 */
public IssuesUserFilter(EventList source){
  super(source);
  source.addListEventListener(new ConsistencyTestList(source,"String_Node_Str"));
  SortedList sortedSource=new SortedList(source);
  sortedSource.addListEventListener(new ConsistencyTestList(sortedSource,"String_Node_Str"));
  usersEventList=new UniqueList(new IssuesToUserList(source));
  ((UniqueList)usersEventList).debug=true;
  usersEventList.addListEventListener(new ConsistencyTestList(usersEventList,"String_Node_Str"));
  EventListModel usersListModel=new EventListModel(usersEventList);
  userSelect=new JList(usersListModel);
  EventSelectionModel userSelectionModel=new EventSelectionModel(usersEventList);
  userSelect.setSelectionModel(userSelectionModel.getListSelectionModel());
  usersSelectedList=userSelectionModel.getEventList();
  userSelect.addListSelectionListener(this);
  handleFilterChanged();
}

Fixed version (ground truth):
/** 
 * Create a filter list that filters the specified source list, which must contain only Issue objects.
 */
public IssuesUserFilter(EventList source){
  super(source);
  source.addListEventListener(new ConsistencyTestList(source,"String_Node_Str"));
  SortedList sortedSource=new SortedList(source);
  sortedSource.addListEventListener(new ConsistencyTestList(sortedSource,"String_Node_Str",true));
  usersEventList=new UniqueList(new IssuesToUserList(source));
  usersEventList.addListEventListener(new ConsistencyTestList(usersEventList,"String_Node_Str",true));
  EventListModel usersListModel=new EventListModel(usersEventList);
  userSelect=new JList(usersListModel);
  EventSelectionModel userSelectionModel=new EventSelectionModel(usersEventList);
  userSelect.setSelectionModel(userSelectionModel.getListSelectionModel());
  usersSelectedList=userSelectionModel.getEventList();
  userSelect.addListSelectionListener(this);
  handleFilterChanged();
}
Program: 32842
Project: 32842
Buggy source:
/** 
 * When the list is changed the change may create new duplicates or remove duplicates.  The list is then altered to restore uniqeness and the events describing the alteration of the unique view are forwarded on.
 * @param listChanges The group of list changes to process
 */
public void listChanged(ListEvent listChanges){
  List nonUniqueInserts=new ArrayList();
  updates.beginEvent();
  while (listChanges.next()) {
    int changeIndex=listChanges.getIndex();
    int changeType=listChanges.getType();
    int changeResult=-1;
    if (changeType == ListEvent.INSERT) {
      changeResult=processInsertEvent(changeIndex);
    }
 else     if (changeType == ListEvent.DELETE) {
      processDeleteEvent(changeIndex);
    }
 else     if (changeType == ListEvent.UPDATE) {
      changeResult=processUpdateEvent(changeIndex);
    }
    if (changeResult != -1) {
      nonUniqueInserts.add(new Integer(changeResult));
    }
  }
  int uniqueInsertSize=nonUniqueInserts.size();
  for (int i=0; i < uniqueInsertSize; i++) {
    int insertIndex=((Integer)nonUniqueInserts.get(i)).intValue();
    guaranteeUniqueness(insertIndex);
  }
  updates.commitEvent();
}

Fixed version (ground truth):
/** 
 * When the list is changed the change may create new duplicates or remove duplicates.  The list is then altered to restore uniqeness and the events describing the alteration of the unique view are forwarded on.
 * @param listChanges The group of list changes to process
 */
public void listChanged(ListEvent listChanges){
  List nonUniqueInserts=new ArrayList();
  updates.beginEvent();
  while (listChanges.next()) {
    int changeIndex=listChanges.getIndex();
    int changeType=listChanges.getType();
    int changeResult=-1;
    if (changeType == ListEvent.INSERT) {
      changeResult=processInsertEvent(changeIndex);
    }
 else     if (changeType == ListEvent.DELETE) {
      processDeleteEvent(changeIndex);
    }
 else     if (changeType == ListEvent.UPDATE) {
      changeResult=processUpdateEvent(changeIndex);
    }
    if (changeResult != -1) {
      nonUniqueInserts.add(new Integer(changeResult));
      updateIndexOffset++;
    }
  }
  updateIndexOffset=0;
  int uniqueInsertSize=nonUniqueInserts.size();
  for (int i=0; i < uniqueInsertSize; i++) {
    int insertIndex=((Integer)nonUniqueInserts.get(i)).intValue();
    guaranteeUniqueness(insertIndex);
  }
  updates.commitEvent();
}
Program: 32843
Project: 32843
Buggy source:
/** 
 * Appends a change to the ListEventAssembler. <p>This is to handle the case where more verbosity could add value to lists listening to changes on the unique list.
 * @param index The index of the change
 * @param type The type of this change
 * @param mandatory Whether or not to propagate this change to all listeners
 */
private void addChange(int type,int index,boolean mandatory){
  if (mandatory) {
    updates.addChange(type,index);
  }
 else {
  }
}

Fixed version (ground truth):
/** 
 * Appends a change to the ListEventAssembler. <p>This is to handle the case where more verbosity could add value to lists listening to changes on the unique list.
 * @param index The index of the change
 * @param type The type of this change
 * @param mandatory Whether or not to propagate this change to all listeners
 */
private void addChange(int type,int index,boolean mandatory){
  if (mandatory) {
    updates.addChange(type,index - updateIndexOffset);
  }
 else {
  }
}
Program: 32844
Project: 32844
Buggy source:
/** 
 * Gets this event as a String. This simply iterates through all blocks and concatenates them.
 */
public String toString(){
  StringBuffer result=new StringBuffer();
  result.append("String_Node_Str" + atomicCount + "String_Node_Str");
  for (int b=0; b < masterSequence.getBlockCount(atomicCount); b++) {
    if (b != 0)     result.append("String_Node_Str");
    result.append(masterSequence.getBlock(atomicCount,b));
  }
  return result.toString();
}

Fixed version (ground truth):
/** 
 * Gets this event as a String. This simply iterates through all blocks and concatenates them.
 */
public String toString(){
  StringBuffer result=new StringBuffer();
  result.append("String_Node_Str" + atomicCount + "String_Node_Str");
  int atomicChangeToShow=0;
  if (atomicCount < masterSequence.getAtomicCount())   atomicChangeToShow=masterSequence.getAtomicCount();
 else   atomicChangeToShow=masterSequence.getAtomicCount()=1;
  int blocksToShow=masterSequence.getBlockCount(atomicChangeToShow);
  for (int b=0; b < blocksToShow; b++) {
    if (b != 0)     result.append("String_Node_Str");
    result.append(masterSequence.getBlock(atomicChangeToShow,b));
  }
  return result.toString();
}
Program: 32845
Project: 32845
Buggy source:
/** 
 * Replaces the object at the specified index in the source list with the specified value. <p>This has been modified for UniqueList in order to remove all of the elements at the source index with a single instance of the specified element. <p><strong>Warning:</strong> Because the set() method is implemented using <i>multiple</i> modifying calls to the source list, <i>multiple</i> events will be propogated. Therefore this method has been carefully implemented to keep this list in a consistent state for each such modifying operation.
 */
public Object set(int index,Object value){
  getReadWriteLock().writeLock().lock();
  try {
    if (!isWritable())     throw new IllegalStateException("String_Node_Str");
    if (index < 0 || index >= size())     throw new ArrayIndexOutOfBoundsException("String_Node_Str" + index + "String_Node_Str"+ size());
    Object replaced=get(index);
    updates.beginEvent(true);
    remove(index);
    add(index,value);
    updates.commitEvent();
    return replaced;
  }
  finally {
    getReadWriteLock().writeLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * Replaces the object at the specified index in the source list with the specified value. <p>This removes all duplicates of the replaced value, then sets the replacement value on the source list. <p><strong>Warning:</strong> Because the set() method is implemented using <i>multiple</i> modifying calls to the source list, <i>multiple</i> events will be propogated. Therefore this method has been carefully implemented to keep this list in a consistent state for each such modifying operation.
 */
public Object set(int index,Object value){
  getReadWriteLock().writeLock().lock();
  try {
    if (!isWritable())     throw new IllegalStateException("String_Node_Str");
    if (index < 0 || index >= size())     throw new ArrayIndexOutOfBoundsException("String_Node_Str" + index + "String_Node_Str"+ size());
    Object replaced=get(index);
    updates.beginEvent(true);
    int removeStart=-1;
    int removeEnd=-1;
    if (index < size() - 1) {
      removeStart=getSourceIndex(index) + 1;
      removeEnd=getSourceIndex(index + 1);
    }
 else {
      removeStart=getSourceIndex(index) + 1;
      removeEnd=source.size();
    }
    if (removeStart < removeEnd) {
      source.subList(removeStart,removeEnd).clear();
    }
    source.set(getSourceIndex(index),value);
    updates.commitEvent();
    return replaced;
  }
  finally {
    getReadWriteLock().writeLock().unlock();
  }
}
Program: 32846
Project: 32846
Buggy source:
/** 
 * Removes the specified list from the lists that compose this list.
 */
public void removeMemberList(EventList list){
  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.beginEvent();
    updates.addDelete(offset,offset + memberList.size() - 1);
    updates.commitEvent();
  }
}

Fixed version (ground truth):
/** 
 * Removes the specified list from the lists that compose this list.
 */
public void removeMemberList(EventList list){
  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");
  memberList.getSourceList().removeListEventListener(memberList);
  int offset=getListOffset(memberList);
  memberLists.remove(memberList);
  if (memberList.size() > 0) {
    updates.beginEvent();
    updates.addDelete(offset,offset + memberList.size() - 1);
    updates.commitEvent();
  }
}
Program: 32847
Project: 32847
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();
}

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 RuntimeException("String_Node_Str" + memberList);
}
Program: 32848
Project: 32848
Buggy source:
/** 
 * Commits the current atomic change to this list change queue. This will notify all listeners about the change.
 */
public synchronized void commitEvent(){
  if (atomicChangeBlocks.size() > 0) {
    ListEventBlock.sortListEventBlocks(atomicChangeBlocks);
    atomicChanges.add(atomicChangeBlocks);
    try {
      for (int i=0; i < listeners.size(); i++) {
        ListEventListener listener=(ListEventListener)listeners.get(i);
        ListEvent event=(ListEvent)listenerEvents.get(i);
        listener.listChanged(event);
      }
    }
  finally {
      atomicChangeBlocks=null;
      atomicLatestBlock=null;
    }
  }
 else {
    atomicChangeBlocks=null;
    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 commitEvent(){
  if (atomicChangeBlocks.size() > 0) {
    ListEventBlock.sortListEventBlocks(atomicChangeBlocks);
    atomicChanges.add(atomicChangeBlocks);
    try {
      List listenersToNotify=new ArrayList();
      List listenerEventsToNotify=new ArrayList();
      listenersToNotify.addAll(listeners);
      listenerEventsToNotify.addAll(listenerEvents);
      for (int i=0; i < listenersToNotify.size(); i++) {
        ListEventListener listener=(ListEventListener)listenersToNotify.get(i);
        ListEvent event=(ListEvent)listenerEventsToNotify.get(i);
        listener.listChanged(event);
      }
    }
  finally {
      atomicChangeBlocks=null;
      atomicLatestBlock=null;
    }
  }
 else {
    atomicChangeBlocks=null;
    atomicLatestBlock=null;
  }
}
Program: 32849
Project: 32849
Buggy source:
/** 
 * Removes from this collection all of its elements that are contained in the specified collection (optional operation). This method has been is available in this implementation, although the not particularly high performance.
 */
public boolean removeAll(Collection collection){
  getReadWriteLock().writeLock().lock();
  try {
    boolean changed=false;
    updates.beginEvent();
    for (Iterator i=collection.iterator(); i.hasNext(); ) {
      int index=-1;
      while ((index=data.indexOf(i.next())) != -1) {
        updates.addDelete(index);
        data.remove(index);
        changed=true;
      }
    }
    updates.commitEvent();
    return changed;
  }
  finally {
    getReadWriteLock().writeLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * Removes from this collection all of its elements that are contained in the specified collection (optional operation). This method has been is available in this implementation, although the not particularly high performance.
 */
public boolean removeAll(Collection collection){
  getReadWriteLock().writeLock().lock();
  try {
    boolean changed=false;
    updates.beginEvent();
    for (Iterator i=collection.iterator(); i.hasNext(); ) {
      int index=-1;
      if ((index=data.indexOf(i.next())) != -1) {
        updates.addDelete(index);
        data.remove(index);
        changed=true;
      }
    }
    updates.commitEvent();
    return changed;
  }
  finally {
    getReadWriteLock().writeLock().unlock();
  }
}
Program: 32850
Project: 32850
Buggy source:
/** 
 * Removes the specified element from the source list. <p>Like all modifying methods, this method manages its own thread safety via the <code>getReadWriteLock().writeLock()</code>. To perform several changes atomically, obtain the write lock before the first change and release it after the last change.
 * @throws IllegalStateException if this mutation cannot be modified in itscurrent state.
 */
public boolean remove(Object toRemove){
  getReadWriteLock().writeLock().lock();
  try {
    if (!isWritable())     throw new IllegalStateException("String_Node_Str");
    return source.remove(toRemove);
  }
  finally {
    getReadWriteLock().writeLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * Removes the specified element from the source list. <p>Like all modifying methods, this method manages its own thread safety via the <code>getReadWriteLock().writeLock()</code>. To perform several changes atomically, obtain the write lock before the first change and release it after the last change.
 * @throws IllegalStateException if this mutation cannot be modified in itscurrent state.
 */
public boolean remove(Object toRemove){
  getReadWriteLock().writeLock().lock();
  try {
    if (!isWritable())     throw new IllegalStateException("String_Node_Str");
    int index=indexOf(toRemove);
    if (index == -1)     return false;
    source.remove(getSourceIndex(index));
    return true;
  }
  finally {
    getReadWriteLock().writeLock().unlock();
  }
}
Program: 32851
Project: 32851
Buggy source:
/** 
 * Removes the specified elements from the source list. <p>Like all modifying methods, this method manages its own thread safety via the <code>getReadWriteLock().writeLock()</code>. To perform several changes atomically, obtain the write lock before the first change and release it after the last change.
 * @throws IllegalStateException if this mutation cannot be modified in itscurrent state.
 */
public boolean removeAll(Collection values){
  getReadWriteLock().writeLock().lock();
  try {
    if (!isWritable())     throw new IllegalStateException("String_Node_Str");
    return source.removeAll(values);
  }
  finally {
    getReadWriteLock().writeLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * Removes the specified elements from the source list. <p>Like all modifying methods, this method manages its own thread safety via the <code>getReadWriteLock().writeLock()</code>. To perform several changes atomically, obtain the write lock before the first change and release it after the last change.
 * @throws IllegalStateException if this mutation cannot be modified in itscurrent state.
 */
public boolean removeAll(Collection values){
  getReadWriteLock().writeLock().lock();
  try {
    if (!isWritable())     throw new IllegalStateException("String_Node_Str");
    boolean overallChanged=false;
    for (Iterator i=values.iterator(); i.hasNext(); ) {
      boolean removeChanged=remove(i.next());
      if (removeChanged)       overallChanged=true;
    }
    return overallChanged;
  }
  finally {
    getReadWriteLock().writeLock().unlock();
  }
}
Program: 32852
Project: 32852
Buggy source:
/** 
 * Removes <strong>all</strong> elements from the source list, even those that are not displayed from this view. In order to remove only the elements displayed by this view, iterate through this list to remove its elements one at a time. <p>Like all modifying methods, this method manages its own thread safety via the <code>getReadWriteLock().writeLock()</code>. To perform several changes atomically, obtain the write lock before the first change and release it after the last change.
 * @throws IllegalStateException if this mutation cannot be modified in itscurrent state.
 */
public void clear(){
  getReadWriteLock().writeLock().lock();
  try {
    if (!isWritable())     throw new IllegalStateException("String_Node_Str");
    source.clear();
  }
  finally {
    getReadWriteLock().writeLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * Removes <strong>all</strong> elements from the source list, even those that are not displayed from this view. In order to remove only the elements displayed by this view, iterate through this list to remove its elements one at a time. <p>Like all modifying methods, this method manages its own thread safety via the <code>getReadWriteLock().writeLock()</code>. To perform several changes atomically, obtain the write lock before the first change and release it after the last change.
 * @throws IllegalStateException if this mutation cannot be modified in itscurrent state.
 */
public void clear(){
  getReadWriteLock().writeLock().lock();
  try {
    if (!isWritable())     throw new IllegalStateException("String_Node_Str");
    for (ListIterator i=listIterator(); i.hasNext(); ) {
      i.next();
      i.remove();
    }
  }
  finally {
    getReadWriteLock().writeLock().unlock();
  }
}
Program: 32853
Project: 32853
Buggy source:
/** 
 * Retains only the values from the source list that are in the specified collection. <p>Like all modifying methods, this method manages its own thread safety via the <code>getReadWriteLock().writeLock()</code>. To perform several changes atomically, obtain the write lock before the first change and release it after the last change.
 * @throws IllegalStateException if this mutation cannot be modified in itscurrent state.
 */
public boolean retainAll(Collection values){
  getReadWriteLock().writeLock().lock();
  try {
    if (!isWritable())     throw new IllegalStateException("String_Node_Str");
    return source.retainAll(values);
  }
  finally {
    getReadWriteLock().writeLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * Retains only the values from the source list that are in the specified collection. <p>Like all modifying methods, this method manages its own thread safety via the <code>getReadWriteLock().writeLock()</code>. To perform several changes atomically, obtain the write lock before the first change and release it after the last change.
 * @throws IllegalStateException if this mutation cannot be modified in itscurrent state.
 */
public boolean retainAll(Collection values){
  getReadWriteLock().writeLock().lock();
  try {
    if (!isWritable())     throw new IllegalStateException("String_Node_Str");
    boolean changed=false;
    for (ListIterator i=listIterator(); i.hasNext(); ) {
      if (!values.contains(i.next())) {
        i.remove();
        changed=true;
      }
    }
    return changed;
  }
  finally {
    getReadWriteLock().writeLock().unlock();
  }
}