nus-yam/ex-repair huggingface dataset:
Program: 32435
Project: 32435
Buggy source:
/** 
 * Registers the specified listener to be notified whenever new changes are appended to this list change sequence. <p>For each listener, a ListEvent is created, which provides a read-only view to the list changes in the list. The same ListChangeView object is used for all notifications to the specified listener, so if a listener does not process a set of changes, those changes will persist in the next notification.
 */
public synchronized void addListEventListener(ListEventListener<? super E> listChangeListener){
  publisher.addListener(sourceList,listChangeListener,eventFormat);
}

Fixed version (ground truth):
/** 
 * Registers the specified listener to be notified whenever new changes are appended to this list change sequence. <p>For each listener, a ListEvent is created, which provides a read-only view to the list changes in the list. The same ListChangeView object is used for all notifications to the specified listener, so if a listener does not process a set of changes, those changes will persist in the next notification.
 * @param listChangeListener event listener != null
 * @throws NullPointerException if the specified listener is null
 */
public synchronized void addListEventListener(ListEventListener<? super E> listChangeListener){
  Preconditions.checkNotNull(listChangeListener,"String_Node_Str");
  publisher.addListener(sourceList,listChangeListener,eventFormat);
}
Program: 32436
Project: 32436
Buggy source:
/** 
 * Removes the specified listener from receiving notification when new changes are appended to this list change sequence. <p>This uses the <code>==</code> identity comparison to find the listener instead of <code>equals()</code>. This is because multiple Lists may be listening and therefore <code>equals()</code> may be ambiguous.
 */
public synchronized void removeListEventListener(ListEventListener<? super E> listChangeListener){
  publisher.removeListener(sourceList,listChangeListener);
}

Fixed version (ground truth):
/** 
 * Removes the specified listener from receiving notification when new changes are appended to this list change sequence. <p>This uses the <code>==</code> identity comparison to find the listener instead of <code>equals()</code>. This is because multiple Lists may be listening and therefore <code>equals()</code> may be ambiguous.
 * @param listChangeListener event listener != null
 * @throws NullPointerException if the specified listener is null
 * @throws IllegalArgumentException if the specified listener wasn't added before
 */
public synchronized void removeListEventListener(ListEventListener<? super E> listChangeListener){
  Preconditions.checkNotNull(listChangeListener,"String_Node_Str");
  publisher.removeListener(sourceList,listChangeListener);
}
Program: 32437
Project: 32437
Buggy source:
/** 
 * Wraps the source in an   {@link EventList} that does not allow writing operations.<p>The returned  {@link EventList} is useful for programming defensively. A{@link EventList} is useful to supply an unknown class read-only accessto your  {@link EventList}. <p>The returned   {@link EventList} will provides an up-to-date view of its source{@link EventList} so changes to the source {@link EventList} will still bereflected. For a static copy of any  {@link EventList} it is necessary to copythe contents of that  {@link EventList} into an {@link ArrayList}. <p><strong><font color="#FF0000">Warning:</font></strong> This returned EventList is thread ready but not thread safe. See   {@link EventList} for an exampleof thread safe code.
 */
public static <E>TransformedList<E,E> readOnlyList(EventList<E> source){
  return new ReadOnlyList<E>(source);
}

Fixed version (ground truth):
/** 
 * Wraps the source in an   {@link EventList} that does not allow writing operations.<p>The returned  {@link EventList} is useful for programming defensively. A{@link EventList} is useful to supply an unknown class read-only accessto your  {@link EventList}. <p>The returned   {@link EventList} will provides an up-to-date view of its source{@link EventList} so changes to the source {@link EventList} will still bereflected. For a static copy of any  {@link EventList} it is necessary to copythe contents of that  {@link EventList} into an {@link ArrayList}. <p><strong><font color="#FF0000">Warning:</font></strong> This returned EventList is thread ready but not thread safe. See   {@link EventList} for an exampleof thread safe code.
 */
public static <E>TransformedList<E,E> readOnlyList(EventList<? extends E> source){
  return new ReadOnlyList<E>((EventList<E>)source);
}
Program: 32438
Project: 32438
Buggy source:
/** 
 * Wraps the source in an   {@link EventList} that obtains a{@link ca.odell.glazedlists.util.concurrent.ReadWriteLock ReadWritLock} for alloperations. <p>This provides some support for sharing  {@link EventList}s between multiple threads. <p>Using a   {@link ThreadSafeList} for concurrent access to lists can be expensivebecause a  {@link ca.odell.glazedlists.util.concurrent.ReadWriteLock ReadWriteLock}is aquired and released for every operation. <p><strong><font color="#FF0000">Warning:</font></strong> Although this class provides thread safe access, it does not provide any guarantees that changes will not happen between method calls. For example, the following code is unsafe because the source   {@link EventList} may change between calls to{@link TransformedList#size() size()} and {@link TransformedList#get(int) get()}: <pre> EventList source = ... ThreadSafeList myList = new ThreadSafeList(source); if(myList.size() > 3) { System.out.println(myList.get(3)); }</pre> <p><strong><font color="#FF0000">Warning:</font></strong> The objects returned by   {@link TransformedList#iterator() iterator()},  {@link TransformedList#subList(int,int) subList()}, etc. are not thread safe.
 * @see ca.odell.glazedlists.util.concurrent
 */
public static <E>TransformedList<E,E> threadSafeList(EventList<E> source){
  return new ThreadSafeList<E>(source);
}

Fixed version (ground truth):
/** 
 * Wraps the source in an   {@link EventList} that obtains a{@link ca.odell.glazedlists.util.concurrent.ReadWriteLock ReadWritLock} for alloperations. <p>This provides some support for sharing  {@link EventList}s between multiple threads. <p>Using a   {@link ThreadSafeList} for concurrent access to lists can be expensivebecause a  {@link ca.odell.glazedlists.util.concurrent.ReadWriteLock ReadWriteLock}is aquired and released for every operation. <p><strong><font color="#FF0000">Warning:</font></strong> Although this class provides thread safe access, it does not provide any guarantees that changes will not happen between method calls. For example, the following code is unsafe because the source   {@link EventList} may change between calls to{@link TransformedList#size() size()} and {@link TransformedList#get(int) get()}: <pre> EventList source = ... ThreadSafeList myList = new ThreadSafeList(source); if(myList.size() > 3) { System.out.println(myList.get(3)); }</pre> <p><strong><font color="#FF0000">Warning:</font></strong> The objects returned by   {@link TransformedList#iterator() iterator()},  {@link TransformedList#subList(int,int) subList()}, etc. are not thread safe.
 * @see ca.odell.glazedlists.util.concurrent
 */
public static <E>TransformedList<E,E> threadSafeList(EventList<? extends E> source){
  return new ThreadSafeList<E>((EventList<E>)source);
}
Program: 32439
Project: 32439
Buggy source:
/** 
 * Test for <a href="https://glazedlists.dev.java.net/issues/show_bug.cgi?id=489">bug 489</a> 
 */
public void testDeletionIssues_FixMe(){
  EventList<String> source=new BasicEventList<String>();
  TreeList<String> treeList=new TreeList<String>(source,COMPRESSED_CHARACTER_TREE_FORMAT,TreeList.NODES_START_EXPANDED);
  ListConsistencyListener<String> listConsistencyListener=ListConsistencyListener.install(treeList);
  listConsistencyListener.setPreviousElementTracked(false);
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  assertTreeStructure(treeList,new String[]{"String_Node_Str","String_Node_Str"});
  source.add(0,"String_Node_Str");
  assertTreeStructure(treeList,new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"});
  source.remove(0);
  assertTreeStructure(treeList,new String[]{"String_Node_Str","String_Node_Str"});
  source.set(1,"String_Node_Str");
  assertTreeStructure(treeList,new String[]{"String_Node_Str","String_Node_Str"});
}

Fixed version (ground truth):
/** 
 * Test for <a href="https://glazedlists.dev.java.net/issues/show_bug.cgi?id=489">bug 489</a> 
 */
public void testDeletionIssues_FixMe(){
  EventList<String> source=new BasicEventList<String>();
  TreeList<String> treeList=new TreeList<String>(source,COMPRESSED_CHARACTER_TREE_FORMAT,TreeList.NODES_START_EXPANDED);
  ListConsistencyListener<String> listConsistencyListener=ListConsistencyListener.install(treeList);
  listConsistencyListener.setPreviousElementTracked(false);
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  assertTreeStructure(treeList,new String[]{"String_Node_Str","String_Node_Str"});
  source.add(0,"String_Node_Str");
  assertTreeStructure(treeList,new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"});
  source.remove(1);
  assertTreeStructure(treeList,new String[]{"String_Node_Str","String_Node_Str"});
  source.set(1,"String_Node_Str");
  assertTreeStructure(treeList,new String[]{"String_Node_Str","String_Node_Str"});
}
Program: 32440
Project: 32440
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public Rectangle getCellRect(int row,int column,boolean includeSpacing){
  final AdvancedTableModel eventTableModel=getEventTableModel();
  if (row >= eventTableModel.getRowCount()) {
    return new Rectangle();
  }
  Object rowValue=eventTableModel.getElementAt(row);
  if (rowValue instanceof SeparatorList.Separator) {
    Rectangle firstColumn=super.getCellRect(row,0,includeSpacing);
    Rectangle lastColumn=super.getCellRect(row,getColumnCount() - 1,includeSpacing);
    return firstColumn.union(lastColumn);
  }
 else {
    return super.getCellRect(row,column,includeSpacing);
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public Rectangle getCellRect(int row,int column,boolean includeSpacing){
  final AdvancedTableModel eventTableModel=getEventTableModel();
  if (row >= eventTableModel.getRowCount()) {
    return new Rectangle();
  }
  if (row >= 0) {
    final Object rowValue=eventTableModel.getElementAt(row);
    if (rowValue instanceof SeparatorList.Separator) {
      final Rectangle firstColumn=super.getCellRect(row,0,includeSpacing);
      final Rectangle lastColumn=super.getCellRect(row,getColumnCount() - 1,includeSpacing);
      return firstColumn.union(lastColumn);
    }
  }
  return super.getCellRect(row,column,includeSpacing);
}
Program: 32441
Project: 32441
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public int indexOf(Object object){
  if (mode != STRICT_SORT_ORDER || comparator == null)   return source.indexOf(object);
  int index=((SimpleTree)sorted).indexOfValue(object,true,false,ALL_COLORS);
  if (index == -1)   return -1;
  for (; index < size(); index++) {
    E objectAtIndex=get(index);
    if (comparator.compare((E)object,objectAtIndex) != 0)     return -1;
    if (GlazedListsImpl.equal(object,objectAtIndex))     return index;
  }
  return -1;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public int indexOf(Object object){
  if (mode != STRICT_SORT_ORDER || comparator == null)   return super.indexOf(object);
  int index=((SimpleTree)sorted).indexOfValue(object,true,false,ALL_COLORS);
  if (index == -1)   return -1;
  for (; index < size(); index++) {
    E objectAtIndex=get(index);
    if (comparator.compare((E)object,objectAtIndex) != 0)     return -1;
    if (GlazedListsImpl.equal(object,objectAtIndex))     return index;
  }
  return -1;
}
Program: 32442
Project: 32442
Buggy source:
public void testRemovedValueInListEvent(){
  EventList<String> original=new BasicEventList<String>();
  original.addAll(GlazedListsTests.stringToList("String_Node_Str"));
  SortedList<String> sorted=SortedList.create(original);
  ListConsistencyListener<String> listConsistencyListener=ListConsistencyListener.install(sorted);
  listConsistencyListener.setPreviousElementTracked(true);
  original.removeAll(GlazedListsTests.stringToList("String_Node_Str"));
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sorted);
  original.set(1,"String_Node_Str");
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),original);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sorted);
  original.set(2,"String_Node_Str");
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),original);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sorted);
  sorted.setMode(SortedList.AVOID_MOVING_ELEMENTS);
  original.set(1,"String_Node_Str");
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),original);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sorted);
}

Fixed version (ground truth):
public void testRemovedValueInListEvent(){
  EventList<String> original=new BasicEventList<String>();
  original.addAll(GlazedListsTests.stringToList("String_Node_Str"));
  SortedList<String> sorted=SortedList.create(original);
  ListConsistencyListener<String> listConsistencyListener=ListConsistencyListener.install(sorted);
  listConsistencyListener.setPreviousElementTracked(true);
  original.removeAll(GlazedListsTests.stringToList("String_Node_Str"));
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),original);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sorted);
  assertEquals(1,original.indexOf("String_Node_Str"));
  assertEquals(3,sorted.indexOf("String_Node_Str"));
  original.set(1,"String_Node_Str");
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),original);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sorted);
  assertEquals(1,original.indexOf("String_Node_Str"));
  assertEquals(3,sorted.indexOf("String_Node_Str"));
  assertEquals(-1,original.indexOf("String_Node_Str"));
  assertEquals(-1,sorted.indexOf("String_Node_Str"));
  original.set(2,"String_Node_Str");
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),original);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sorted);
  assertEquals(2,original.indexOf("String_Node_Str"));
  assertEquals(3,sorted.indexOf("String_Node_Str"));
  sorted.setMode(SortedList.AVOID_MOVING_ELEMENTS);
  original.set(1,"String_Node_Str");
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),original);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sorted);
  assertEquals(1,original.indexOf("String_Node_Str"));
  assertEquals(0,sorted.indexOf("String_Node_Str"));
  assertEquals(1,sorted.indexOf("String_Node_Str"));
  assertEquals(2,sorted.indexOf("String_Node_Str"));
}
Program: 32445
Project: 32445
Buggy source:
/** 
 * Handle a listener being notified for the specified <code>listElement</code>. This method causes a ListEvent to be fired from this EventList indicating an update occurred at all locations of the given <code>listElement</code>. <p>Note that listElement must be the exact object located within this list (i.e. <code>listElement == get(i) for some i >= 0</code>). <p>This method acquires the write lock for this list before locating the <code>listElement</code> and broadcasting its update. It is assumed that this method may be called on any Thread, so to decrease the burdens of the caller in achieving multi-threaded correctness, this method is Thread ready.
 * @param listElement the list element which has been modified
 */
public void elementChanged(E listElement){
  if (this.observedElements == null)   throw new IllegalStateException("String_Node_Str");
  getReadWriteLock().writeLock().lock();
  try {
    this.updates.beginEvent();
    for (int i=0, n=size(); i < n; i++) {
      if (listElement == get(i))       this.updates.elementUpdated(i,listElement);
    }
    this.updates.commitEvent();
  }
  finally {
    getReadWriteLock().writeLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * Handle a listener being notified for the specified <code>listElement</code>. This method causes a ListEvent to be fired from this EventList indicating an update occurred at all locations of the given <code>listElement</code>. <p>Note that listElement must be the exact object located within this list (i.e. <code>listElement == get(i) for some i >= 0</code>). <p>This method acquires the write lock for this list before locating the <code>listElement</code> and broadcasting its update. It is assumed that this method may be called on any Thread, so to decrease the burdens of the caller in achieving multi-threaded correctness, this method is Thread ready.
 * @param listElement the list element which has been modified
 */
public void elementChanged(Object listElement){
  if (this.observedElements == null)   throw new IllegalStateException("String_Node_Str");
  getReadWriteLock().writeLock().lock();
  try {
    this.updates.beginEvent();
    for (int i=0, n=size(); i < n; i++) {
      final E currentElement=get(i);
      if (listElement == currentElement) {
        this.updates.elementUpdated(i,currentElement);
      }
    }
    this.updates.commitEvent();
  }
  finally {
    getReadWriteLock().writeLock().unlock();
  }
}
Program: 32446
Project: 32446
Buggy source:
/** 
 * This method is called whenever the observed object is changed. It responds by notifying the associated ObservableElementList that the given  {@link Observable} has been changed.
 * @param o the Observable that has been updated
 * @param arg an argument passed to observers which is ignored here
 */
public void update(Observable o,Object arg){
  ((ObservableElementList)list).elementChanged(o);
}

Fixed version (ground truth):
/** 
 * This method is called whenever the observed object is changed. It responds by notifying the associated ObservableElementList that the given  {@link Observable} has been changed.
 * @param o the Observable that has been updated
 * @param arg an argument passed to observers which is ignored here
 */
public void update(Observable o,Object arg){
  list.elementChanged(o);
}
Program: 32447
Project: 32447
Buggy source:
public void propertyChange(PropertyChangeEvent event){
  if (getEventMatcher().matches(event))   ((ObservableElementList)list).elementChanged(event.getSource());
}

Fixed version (ground truth):
public void propertyChange(PropertyChangeEvent event){
  if (getEventMatcher().matches(event)) {
    list.elementChanged(event.getSource());
  }
}
Program: 32448
Project: 32448
Buggy source:
@Override public void elementChanged(E element){
  this.elementChangeCount++;
  super.elementChanged(element);
}

Fixed version (ground truth):
@Override public void elementChanged(Object element){
  this.elementChangeCount++;
  super.elementChanged(element);
}
Program: 32449
Project: 32449
Buggy source:
/** 
 * {@inheritDoc} 
 */
public void setLimit(int limit){
  if (this.limit == limit)   return;
  if (node == null) {
    return;
  }
  this.limit=limit;
  updates.beginEvent();
  int groupIndex=separators.indexOfNode(node,(byte)1);
  int separatorIndex=insertedSeparators.getIndex(groupIndex,SEPARATOR);
  updates.addUpdate(separatorIndex);
  updates.commitEvent();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public void setLimit(int limit){
  applyLimit(limit,true);
}
Program: 32450
Project: 32450
Buggy source:
/** 
 * Statically build the separators data structures.
 */
private void rebuildSeparators(){
  insertedSeparators=new Barcode();
  separators=new SimpleTree<GroupSeparator>();
  insertedSeparators.add(0,SOURCE_ELEMENT,source.size());
  for (BarcodeIterator i=grouper.getBarcode().iterator(); i.hasNextColour(Grouper.UNIQUE); ) {
    i.nextColour(Grouper.UNIQUE);
    int groupIndex=i.getColourIndex(Grouper.UNIQUE);
    int sourceIndex=i.getIndex();
    insertedSeparators.add(groupIndex + sourceIndex,SEPARATOR,1);
    Element<GroupSeparator> node=separators.add(groupIndex,new GroupSeparator(),1);
    node.get().setNode(node);
    node.get().setLimit(defaultLimit);
  }
  for (int i=0; i < separators.size(); i++) {
    separators.get(i).get().updateCachedValues();
  }
}

Fixed version (ground truth):
/** 
 * Statically build the separators data structures.
 */
private void rebuildSeparators(){
  insertedSeparators=new Barcode();
  separators=new SimpleTree<GroupSeparator>();
  insertedSeparators.add(0,SOURCE_ELEMENT,source.size());
  for (BarcodeIterator i=grouper.getBarcode().iterator(); i.hasNextColour(Grouper.UNIQUE); ) {
    i.nextColour(Grouper.UNIQUE);
    int groupIndex=i.getColourIndex(Grouper.UNIQUE);
    int sourceIndex=i.getIndex();
    insertedSeparators.add(groupIndex + sourceIndex,SEPARATOR,1);
    Element<GroupSeparator> node=separators.add(groupIndex,new GroupSeparator(),1);
    node.get().setNode(node);
    node.get().applyLimit(defaultLimit,false);
  }
  for (int i=0; i < separators.size(); i++) {
    separators.get(i).get().updateCachedValues();
  }
}
Program: 32451
Project: 32451
Buggy source:
/** 
 * Validate that this list is as expected.
 */
public void assertConsistent(){
  assertTrue(expected.size() == source.size());
  for (int i=0; i < expected.size(); i++) {
    assertTrue("String_Node_Str" + i,expected.get(i) == source.get(i));
  }
}

Fixed version (ground truth):
/** 
 * Validate that this list is as expected.
 */
public void assertConsistent(){
  assertTrue(expected.size() == source.size());
  for (int i=0; i < expected.size(); i++) {
    assertTrue("String_Node_Str" + i + "String_Node_Str"+ expected.get(i)+ "String_Node_Str"+ source.get(i),expected.get(i) == source.get(i));
  }
}
Program: 32452
Project: 32452
Buggy source:
/** 
 * Returns the current Matcher specified by the source   {@link MatcherEditor}.
 * @return the current Matcher specified by the source {@link MatcherEditor}
 */
@Override public Matcher<E> getMatcher(){
  return this.source.getMatcher();
}

Fixed version (ground truth):
/** 
 * Returns the current Matcher specified by the source   {@link MatcherEditor}.
 * @return the current Matcher specified by the source {@link MatcherEditor}
 */
public Matcher<E> getMatcher(){
  return this.source.getMatcher();
}
Program: 32453
Project: 32453
Buggy source:
/** 
 * This method selects an appropriate delegate method to perform the correct work for each of the possible <code>changeType</code>s. This method does <strong>NOT</strong> acquire any locks and is thus used during initialization of FilterList.
 */
private void changeMatcher(MatcherEditor<? super E> matcherEditor,Matcher<? super E> matcher,int changeType){
  if (currentEditor != matcherEditor)   throw new IllegalStateException();
switch (changeType) {
case MatcherEditor.Event.CONSTRAINED:
    currentMatcher=matcher;
  this.constrained();
break;
case MatcherEditor.Event.RELAXED:
currentMatcher=matcher;
this.relaxed();
break;
case MatcherEditor.Event.CHANGED:
currentMatcher=matcher;
this.changed();
break;
case MatcherEditor.Event.MATCH_ALL:
currentMatcher=Matchers.trueMatcher();
this.matchAll();
break;
case MatcherEditor.Event.MATCH_NONE:
currentMatcher=Matchers.falseMatcher();
this.matchNone();
break;
}
}

Fixed version (ground truth):
/** 
 * This method selects an appropriate delegate method to perform the correct work for each of the possible <code>changeType</code>s. This method does <strong>NOT</strong> acquire any locks and is thus used during initialization of FilterList.
 */
private void changeMatcher(MatcherEditor<? super E> matcherEditor,Matcher<? super E> matcher,int changeType){
  if (!disposed) {
    if (currentEditor != matcherEditor)     throw new IllegalStateException();
switch (changeType) {
case MatcherEditor.Event.CONSTRAINED:
      currentMatcher=matcher;
    this.constrained();
  break;
case MatcherEditor.Event.RELAXED:
currentMatcher=matcher;
this.relaxed();
break;
case MatcherEditor.Event.CHANGED:
currentMatcher=matcher;
this.changed();
break;
case MatcherEditor.Event.MATCH_ALL:
currentMatcher=Matchers.trueMatcher();
this.matchAll();
break;
case MatcherEditor.Event.MATCH_NONE:
currentMatcher=Matchers.falseMatcher();
this.matchNone();
break;
}
}
}
Program: 32454
Project: 32454
Buggy source:
/** 
 * @inheritDoc 
 */
@Override public void dispose(){
  super.dispose();
  if (currentEditor != null) {
    currentEditor.removeMatcherEditorListener(listener);
    currentEditor=null;
  }
  currentMatcher=null;
}

Fixed version (ground truth):
/** 
 * @inheritDoc 
 */
@Override public void dispose(){
  super.dispose();
  if (currentEditor != null) {
    currentEditor.removeMatcherEditorListener(listener);
  }
  disposed=true;
  currentEditor=null;
  currentMatcher=null;
}
Program: 32456
Project: 32456
Buggy source:
/** 
 * This tests a corner case that arose from the first attempt at fixing issue <a href="https://glazedlists.dev.java.net/issues/show_bug.cgi?id=491">491</a>
 */
public void testAddOnFirstAndUpdateOnSecondElement(){
  TransactionList<String> source=new TransactionList<String>(new BasicEventList<String>());
  GroupingList<String> grouped=new GroupingList<String>(source,GlazedListsTests.getFirstLetterComparator());
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  assertEquals("String_Node_Str",grouped.toString());
  System.out.println("String_Node_Str");
  source.beginEvent();
  source.add(1,"String_Node_Str");
  source.set(2,source.get(2));
  source.commitEvent();
  assertEquals("String_Node_Str",grouped.toString());
}

Fixed version (ground truth):
/** 
 * This tests a corner case that arose from the first attempt at fixing issue <a href="https://glazedlists.dev.java.net/issues/show_bug.cgi?id=491">491</a>
 */
public void testAddOnFirstAndUpdateOnSecondElement(){
  TransactionList<String> source=new TransactionList<String>(new BasicEventList<String>());
  GroupingList<String> grouped=new GroupingList<String>(source,GlazedListsTests.getFirstLetterComparator());
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  source.add("String_Node_Str");
  assertEquals("String_Node_Str",grouped.toString());
  source.beginEvent();
  source.add(1,"String_Node_Str");
  source.set(2,source.get(2));
  source.commitEvent();
  assertEquals("String_Node_Str",grouped.toString());
}
Program: 32457
Project: 32457
Buggy source:
/** 
 * Testcase from issue <a href="https://glazedlists.dev.java.net/issues/show_bug.cgi?id=486">486</a>
 */
public void testIssue486(){
  TransactionList<String> txList=new TransactionList<String>(new BasicEventList<String>());
  new GroupingList<String>(txList);
  txList.beginEvent();
  txList.add("String_Node_Str");
  txList.add("String_Node_Str");
  txList.add("String_Node_Str");
  txList.add("String_Node_Str");
  txList.commitEvent();
  txList.beginEvent();
  txList.set(0,txList.get(0));
  txList.set(1,txList.get(1));
  txList.set(2,txList.get(2));
  txList.set(3,txList.get(3));
  txList.commitEvent();
}

Fixed version (ground truth):
/** 
 * Testcase from issue <a href="https://glazedlists.dev.java.net/issues/show_bug.cgi?id=486">486</a>
 */
public void testIssue486(){
  TransactionList<String> txList=new TransactionList<String>(new BasicEventList<String>());
  GroupingList<String> grouped=new GroupingList<String>(txList);
  txList.beginEvent();
  txList.add("String_Node_Str");
  txList.add("String_Node_Str");
  txList.add("String_Node_Str");
  txList.add("String_Node_Str");
  txList.commitEvent();
  assertEquals("String_Node_Str",grouped.toString());
  txList.beginEvent();
  txList.set(0,txList.get(0));
  txList.set(1,txList.get(1));
  txList.set(2,txList.get(2));
  txList.set(3,txList.get(3));
  txList.commitEvent();
  assertEquals("String_Node_Str",grouped.toString());
}
Program: 32458
Project: 32458
Buggy source:
/** 
 * Check list elements for type safety after they are added to an EventList using a   {@link ListEventListener}. The   {@link ListEventListener} whichis installed and returned to the caller (which they may uninstall at their leisure) will throw an  {@link IllegalArgumentException} if itdetects the addition of an element with an unsupported type. <p> This  {@link ListEventListener} is typically used as a tool tocheck invariants of the elements of  {@link EventList}s during software development and testing phases.
 * @param source the {@link EventList} on which to provide type safety
 * @param types the set of types to which each list element must beassignable - note <tt>null</tt> is an acceptable type and indicates the  {@link EventList} expects to contain <tt>null</tt>elements
 * @return the {@link ListEventListener} providing the which provides typesafety checking on the given <code>source</code>. To stop the type safety checking, use {@link EventList#removeListEventListener(ListEventListener)}.
 */
public static <E>ListEventListener<E> typeSafetyListener(EventList<E> source,Set<Class> types){
  return new TypeSafetyListener<E>(source,types);
}

Fixed version (ground truth):
/** 
 * Check list elements for type safety after they are added to an EventList using a   {@link ListEventListener}. The   {@link ListEventListener} which isinstalled and returned to the caller (which they may uninstall at their leisure) will throw an  {@link IllegalArgumentException} if it detects theaddition of an element with an unsupported type. <p> This  {@link ListEventListener} is typically used as a tool to checkinvariants of the elements of  {@link EventList}s during software development and testing phases.
 * @param source the  {@link EventList} on which to provide type safety
 * @param types the set of types to which each list element must be assignable - the set itself must not be <tt>null</tt>, but <tt>null</tt> is an acceptable type within the set and indicates the {@link EventList} expects to contain <tt>null</tt> elements
 * @return the {@link ListEventListener} providing the safety checking onthe given <code>source</code>. To stop the type safety checking, use  {@link EventList#removeListEventListener(ListEventListener)}.
 */
public static <E>ListEventListener<E> typeSafetyListener(EventList<E> source,Set<Class> types){
  return new TypeSafetyListener<E>(source,types);
}
Program: 32459
Project: 32459
Buggy source:
public void run(){
  final String currentText=comboBoxEditorComponent.getText();
  final Object item=findAutoCompleteTerm(currentText);
  String itemText=convertToString(item);
  if (!currentText.equals(itemText)) {
    if (item == NOT_FOUND && !allItemsUnfiltered.isEmpty())     itemText=convertToString(allItemsUnfiltered.get(0));
    comboBoxEditorComponent.setText(itemText);
  }
}

Fixed version (ground truth):
public void run(){
  final JTextField editor=comboBoxEditorComponent;
  if (editor != null) {
    final String currentText=editor.getText();
    final Object item=findAutoCompleteTerm(currentText);
    String itemText=convertToString(item);
    if (!currentText.equals(itemText)) {
      if (item == NOT_FOUND && !allItemsUnfiltered.isEmpty())       itemText=convertToString(allItemsUnfiltered.get(0));
      editor.setText(itemText);
    }
  }
}
Program: 32460
Project: 32460
Buggy source:
public AtLeastMatcherEditor(int minimum){
  this.minimum=minimum;
  currentMatcher=GlazedListsTests.matchAtLeast(minimum);
}

Fixed version (ground truth):
public AtLeastMatcherEditor(int minimum){
  this.minimum=minimum;
  fireChanged(GlazedListsTests.matchAtLeast(minimum));
}
Program: 32461
Project: 32461
Buggy source:
/** 
 * Returns <tt>true</tt> if the current matcher will match nothing.
 */
protected final boolean isCurrentlyMatchingNone(){
  return this.currentMatcher == Matchers.falseMatcher();
}

Fixed version (ground truth):
/** 
 * Returns <tt>true</tt> if the current matcher will match nothing.
 */
protected final boolean isCurrentlyMatchingNone(){
  return currentMatcher == Matchers.falseMatcher();
}
Program: 32462
Project: 32462
Buggy source:
/** 
 * Returns <tt>true</tt> if the current matcher will match everything.
 */
protected final boolean isCurrentlyMatchingAll(){
  return this.currentMatcher == Matchers.trueMatcher();
}

Fixed version (ground truth):
/** 
 * Returns <tt>true</tt> if the current matcher will match everything.
 */
protected final boolean isCurrentlyMatchingAll(){
  return currentMatcher == Matchers.trueMatcher();
}
Program: 32463
Project: 32463
Buggy source:
/** 
 * {@inheritDoc} 
 */
public Matcher<E> getMatcher(){
  return currentMatcher;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public final Matcher<E> getMatcher(){
  return currentMatcher;
}
Program: 32464
Project: 32464
Buggy source:
/** 
 * Indicates that the filter matches all.
 */
protected final void fireMatchAll(){
  this.currentMatcher=Matchers.trueMatcher();
  this.fireChangedMatcher(new MatcherEditor.Event<E>(this,Event.MATCH_ALL,this.currentMatcher));
}

Fixed version (ground truth):
/** 
 * Indicates that the filter matches all.
 */
protected final void fireMatchAll(){
  currentMatcher=Matchers.trueMatcher();
  fireChangedMatcher(createMatchAllEvent(currentMatcher));
}
Program: 32465
Project: 32465
Buggy source:
/** 
 * Indicates that the filter has changed to be more restrictive. This should only be called if all currently filtered items will remain filtered.
 */
protected final void fireConstrained(Matcher<E> matcher){
  if (matcher == null)   throw new NullPointerException();
  this.currentMatcher=matcher;
  this.fireChangedMatcher(new MatcherEditor.Event<E>(this,Event.CONSTRAINED,this.currentMatcher));
}

Fixed version (ground truth):
/** 
 * Indicates that the filter has changed to be more restrictive. This should only be called if all currently filtered items will remain filtered.
 */
protected final void fireConstrained(Matcher<E> matcher){
  if (matcher == null)   throw new NullPointerException();
  currentMatcher=matcher;
  fireChangedMatcher(createConstrainedEvent(currentMatcher));
}
Program: 32466
Project: 32466
Buggy source:
/** 
 * Indicates that the filter has changed in an indeterminate way.
 */
protected final void fireChanged(Matcher<E> matcher){
  if (matcher == null)   throw new NullPointerException();
  this.currentMatcher=matcher;
  this.fireChangedMatcher(new MatcherEditor.Event<E>(this,Event.CHANGED,this.currentMatcher));
}

Fixed version (ground truth):
/** 
 * Indicates that the filter has changed in an indeterminate way.
 */
protected final void fireChanged(Matcher<E> matcher){
  if (matcher == null)   throw new NullPointerException();
  currentMatcher=matcher;
  fireChangedMatcher(createChangedEvent(currentMatcher));
}
Program: 32467
Project: 32467
Buggy source:
/** 
 * Indicates that the filter matches none.
 */
protected final void fireMatchNone(){
  this.currentMatcher=Matchers.falseMatcher();
  this.fireChangedMatcher(new MatcherEditor.Event<E>(this,Event.MATCH_NONE,this.currentMatcher));
}

Fixed version (ground truth):
/** 
 * Indicates that the filter matches none.
 */
protected final void fireMatchNone(){
  currentMatcher=Matchers.falseMatcher();
  fireChangedMatcher(createMatchNoneEvent(currentMatcher));
}
Program: 32468
Project: 32468
Buggy source:
/** 
 * Indicates that the filter has changed to be less restrictive. This should only be called if all currently unfiltered items will remain unfiltered.
 */
protected final void fireRelaxed(Matcher<E> matcher){
  if (matcher == null)   throw new NullPointerException();
  this.currentMatcher=matcher;
  this.fireChangedMatcher(new MatcherEditor.Event<E>(this,Event.RELAXED,this.currentMatcher));
}

Fixed version (ground truth):
/** 
 * Indicates that the filter has changed to be less restrictive. This should only be called if all currently unfiltered items will remain unfiltered.
 */
protected final void fireRelaxed(Matcher<E> matcher){
  if (matcher == null)   throw new NullPointerException();
  currentMatcher=matcher;
  fireChangedMatcher(createRelaxedEvent(currentMatcher));
}
Program: 32469
Project: 32469
Buggy source:
public void fireChanged(){
  super.fireChanged(this);
}

Fixed version (ground truth):
public void fireChanged(){
  fireChanged(this);
}
Program: 32470
Project: 32470
Buggy source:
public void fireCleared(){
  super.fireMatchAll();
}

Fixed version (ground truth):
public void fireCleared(){
  fireMatchAll();
}
Program: 32471
Project: 32471
Buggy source:
public void fireConstrained(){
  super.fireConstrained(this);
}

Fixed version (ground truth):
public void fireConstrained(){
  fireConstrained(this);
}
Program: 32472
Project: 32472
Buggy source:
/** 
 * This MatcherEditor's Matcher is itself.
 */
public PrivateMatcherEditor(){
  this.currentMatcher=this;
}

Fixed version (ground truth):
/** 
 * This MatcherEditor's Matcher is itself.
 */
public PrivateMatcherEditor(){
  fireChanged();
}
Program: 32473
Project: 32473
Buggy source:
public void fireRelaxed(){
  super.fireRelaxed(this);
}

Fixed version (ground truth):
public void fireRelaxed(){
  fireRelaxed(this);
}
Program: 32474
Project: 32474
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public int lastIndexOf(Object object){
  if (mode != STRICT_SORT_ORDER || comparator == null)   return source.lastIndexOf(object);
  int index=((SimpleTree)sorted).indexOfValue(object,false,false,ALL_COLORS);
  if (index == -1)   return -1;
  for (; index > -1; index--) {
    E objectAtIndex=get(index);
    if (comparator.compare((E)object,objectAtIndex) != 0)     return -1;
    if (GlazedListsImpl.equal(object,objectAtIndex))     return index;
  }
  return -1;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public int lastIndexOf(Object object){
  if (mode != STRICT_SORT_ORDER || comparator == null)   return super.lastIndexOf(object);
  int index=((SimpleTree)sorted).indexOfValue(object,false,false,ALL_COLORS);
  if (index == -1)   return -1;
  for (; index > -1; index--) {
    E objectAtIndex=get(index);
    if (comparator.compare((E)object,objectAtIndex) != 0)     return -1;
    if (GlazedListsImpl.equal(object,objectAtIndex))     return index;
  }
  return -1;
}
Program: 32477
Project: 32477
Buggy source:
/** 
 * Cleanup all temporary variables necessary while events are being fired.
 */
private void cleanup(){
  eventThread=null;
  blockSequence.reset();
  listDeltas.reset(sourceList.size());
  reorderMap=null;
  listDeltas.setAllowContradictingEvents(false);
}

Fixed version (ground truth):
/** 
 * Cleanup all temporary variables necessary while events are being fired.
 */
private void cleanup(){
  eventThread=null;
  blockSequence.reset();
  listDeltas.reset(sourceList.size());
  reorderMap=null;
  listDeltas.setAllowContradictingEvents(false);
  listEvent.reset();
}
Program: 32478
Project: 32478
Buggy source:
/** 
 * When the components list changes, this updates the panel.
 */
public void listChanged(ListEvent listChanges){
  while (listChanges.next()) {
    int type=listChanges.getType();
    int index=listChanges.getIndex();
    if (type == ListEvent.INSERT) {
      insert(index);
    }
 else     if (type == ListEvent.DELETE) {
      delete(index);
    }
 else     if (type == ListEvent.UPDATE) {
      update(index);
    }
  }
  revalidate();
  repaint();
}

Fixed version (ground truth):
/** 
 * When the components list changes, this updates the panel.
 */
public void listChanged(ListEvent<E> listChanges){
  while (listChanges.next()) {
    int type=listChanges.getType();
    int index=listChanges.getIndex();
    if (type == ListEvent.INSERT) {
      insert(index);
    }
 else     if (type == ListEvent.DELETE) {
      delete(index);
    }
 else     if (type == ListEvent.UPDATE) {
      update(index);
    }
  }
  revalidate();
  repaint();
}
Program: 32479
Project: 32479
Buggy source:
/** 
 * Releases the resources consumed by this   {@link JEventListPanel} so that itmay eventually be garbage collected. <p><strong><font color="#FF0000">Warning:</font></strong> It is an error to call any method on a  {@link JEventListPanel} after it has been disposed.
 */
public void dispose(){
  swingSource.dispose();
}

Fixed version (ground truth):
/** 
 * Releases the resources consumed by this   {@link JEventListPanel} so that itmay eventually be garbage collected. <p><strong><font color="#FF0000">Warning:</font></strong> It is an error to call any method on a  {@link JEventListPanel} after it has been disposed.
 */
public void dispose(){
  swingSource.removeListEventListener(sourceChangeHandler);
  swingSource.dispose();
}
Program: 32480
Project: 32480
Buggy source:
public void start(){
  sillyObjects.add("String_Node_Str");
  sillyObjects.add("String_Node_Str");
  sillyObjects.add("String_Node_Str");
  JEventListPanel panel=new JEventListPanel(sillyObjects,new SillyObjectFormat());
  panel.setBorder(BorderFactory.createMatteBorder(5,5,5,5,Color.RED));
  panel.setElementColumns(1);
  JButton addButton=new JButton("String_Node_Str");
  addButton.addActionListener(new AddAction(sillyObjects));
  JFrame frame=new JFrame("String_Node_Str");
  frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  frame.getContentPane().setLayout(new BorderLayout());
  frame.getContentPane().add(panel,BorderLayout.NORTH);
  frame.getContentPane().add(addButton,BorderLayout.SOUTH);
  frame.pack();
  frame.setVisible(true);
}

Fixed version (ground truth):
public void start(){
  sillyObjects.add("String_Node_Str");
  sillyObjects.add("String_Node_Str");
  sillyObjects.add("String_Node_Str");
  JEventListPanel<String> panel=new JEventListPanel<String>(sillyObjects,new SillyObjectFormat());
  panel.setBorder(BorderFactory.createMatteBorder(5,5,5,5,Color.RED));
  panel.setElementColumns(1);
  JButton addButton=new JButton("String_Node_Str");
  addButton.addActionListener(new AddAction(sillyObjects));
  JFrame frame=new JFrame("String_Node_Str");
  frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  frame.getContentPane().setLayout(new BorderLayout());
  frame.getContentPane().add(panel,BorderLayout.NORTH);
  frame.getContentPane().add(addButton,BorderLayout.SOUTH);
  frame.pack();
  frame.setVisible(true);
}
Program: 32481
Project: 32481
Buggy source:
public JComponent getComponent(Object element,int component){
  final String sillyObject=(String)element;
  if (component == 0) {
    JButton button=new JButton(sillyObject);
    button.addActionListener(new ButtonActionListener(sillyObject));
    return button;
  }
 else   if (component == 1) {
    return new JSlider();
  }
 else   if (component == 2) {
    return new JTextField();
  }
 else {
    throw new IllegalStateException();
  }
}

Fixed version (ground truth):
public JComponent getComponent(String element,int component){
  final String sillyObject=element;
  if (component == 0) {
    JButton button=new JButton(sillyObject);
    button.addActionListener(new ButtonActionListener(sillyObject));
    return button;
  }
 else   if (component == 1) {
    return new JSlider();
  }
 else   if (component == 2) {
    return new JTextField();
  }
 else {
    throw new IllegalStateException();
  }
}
Program: 32482
Project: 32482
Buggy source:
public AddAction(EventList target){
  this.target=target;
}

Fixed version (ground truth):
public AddAction(EventList<String> target){
  this.target=target;
}
Program: 32483
Project: 32483
Buggy source:
public void run(){
  final String currentText=comboBoxEditorComponent.getText();
  final Object item=findAutoCompleteTerm(currentText);
  String itemText=convertToString(item);
  if (!currentText.equals(itemText)) {
    if (item == null && !allItemsUnfiltered.isEmpty())     itemText=convertToString(allItemsUnfiltered.get(0));
    comboBoxEditorComponent.setText(itemText);
  }
}

Fixed version (ground truth):
public void run(){
  final String currentText=comboBoxEditorComponent.getText();
  final Object item=findAutoCompleteTerm(currentText);
  String itemText=convertToString(item);
  if (!currentText.equals(itemText)) {
    if (item == NOT_FOUND && !allItemsUnfiltered.isEmpty())     itemText=convertToString(allItemsUnfiltered.get(0));
    comboBoxEditorComponent.setText(itemText);
  }
}
Program: 32484
Project: 32484
Buggy source:
/** 
 * Performs a linear scan of ALL ITEMS, regardless of the filtering state of the ComboBoxModel, to locate the autocomplete term. If an exact match of the given <code>value</code> can be found, then the item is returned. If an exact match cannot be found, the first term that <strong>starts with</strong> the given <code>value</code> is returned. <p>If no exact or partial match can be located, <code>null</code> is returned.
 */
private Object findAutoCompleteTerm(String value){
  final boolean prefixIsEmpty="String_Node_Str".equals(value);
  final Matcher<String> valueMatcher=new TextMatcher<String>(new SearchTerm[]{new SearchTerm(value)},GlazedLists.toStringTextFilterator(),TextMatcherEditor.STARTS_WITH,getTextMatchingStrategy());
  Object partialMatchItem=null;
  for (int i=0, n=allItemsUnfiltered.size(); i < n; i++) {
    final E item=allItemsUnfiltered.get(i);
    final String itemString=convertToString(item);
    if (value.equals(itemString))     return item;
    if (partialMatchItem == null) {
      if (prefixIsEmpty ? "String_Node_Str".equals(itemString) : valueMatcher.matches(itemString))       partialMatchItem=item;
    }
  }
  return partialMatchItem;
}

Fixed version (ground truth):
/** 
 * Performs a linear scan of ALL ITEMS, regardless of the filtering state of the ComboBoxModel, to locate the autocomplete term. If an exact match of the given <code>value</code> can be found, then the item is returned. If an exact match cannot be found, the first term that <strong>starts with</strong> the given <code>value</code> is returned. <p>If no exact or partial match can be located, <code>null</code> is returned.
 */
private Object findAutoCompleteTerm(String value){
  final boolean prefixIsEmpty="String_Node_Str".equals(value);
  final Matcher<String> valueMatcher=new TextMatcher<String>(new SearchTerm[]{new SearchTerm(value)},GlazedLists.toStringTextFilterator(),TextMatcherEditor.STARTS_WITH,getTextMatchingStrategy());
  Object partialMatchItem=NOT_FOUND;
  for (int i=0, n=allItemsUnfiltered.size(); i < n; i++) {
    final E item=allItemsUnfiltered.get(i);
    final String itemString=convertToString(item);
    if (value.equals(itemString))     return item;
    if (partialMatchItem == NOT_FOUND) {
      if (prefixIsEmpty ? "String_Node_Str".equals(itemString) : valueMatcher.matches(itemString))       partialMatchItem=item;
    }
  }
  return partialMatchItem;
}
Program: 32485
Project: 32485
Buggy source:
/** 
 * A convenience method to produce a String from the given <code>comboBoxElement</code>.
 */
private String convertToString(Object comboBoxElement){
  if (format != null)   return format.format(comboBoxElement);
  return comboBoxElement == null ? "String_Node_Str" : comboBoxElement.toString();
}

Fixed version (ground truth):
/** 
 * A convenience method to produce a String from the given <code>comboBoxElement</code>.
 */
private String convertToString(Object comboBoxElement){
  if (comboBoxElement == NOT_FOUND)   return "String_Node_Str";
  if (format != null)   return format.format(comboBoxElement);
  return comboBoxElement == null ? "String_Node_Str" : comboBoxElement.toString();
}