nus-yam/ex-repair huggingface dataset:
Program: 32486
Project: 32486
Buggy source:
/** 
 * This method generically post processes changes to the ComboBox editor's Document. The generic algorithm, regardless of the type of change, is as follows: <ol> <li> save the prefix as the user has entered it <li> filter the combo box items against the prefix <li> update the text in the combo box editor with an autocomplete suggestion <li> try to show the popup, if possible </ol>
 */
private void postProcessDocumentChange(FilterBypass filterBypass,AttributeSet attributeSet,String valueBeforeEdit,int selectionStart,int selectionEnd,boolean allowPartialAutoCompletionTerm) throws BadLocationException {
  if (doNotPostProcessDocumentChanges)   return;
  final String valueAfterEdit=comboBoxEditorComponent.getText();
  if (isStrict() && findAutoCompleteTerm(valueAfterEdit) == null && !allItemsUnfiltered.isEmpty()) {
    if (getBeepOnStrictViolation())     UIManager.getLookAndFeel().provideErrorFeedback(comboBoxEditorComponent);
    doNotPostProcessDocumentChanges=true;
    try {
      comboBoxEditorComponent.setText(valueBeforeEdit);
    }
  finally {
      doNotPostProcessDocumentChanges=false;
    }
    comboBoxEditorComponent.select(selectionStart,selectionEnd);
    return;
  }
  final Object selectedItemBeforeEdit=comboBox.getSelectedItem();
  updateFilter();
  applyFilter(prefix);
  selectAutoCompleteTerm(filterBypass,attributeSet,selectedItemBeforeEdit,allowPartialAutoCompletionTerm);
  togglePopup();
}

Fixed version (ground truth):
/** 
 * This method generically post processes changes to the ComboBox editor's Document. The generic algorithm, regardless of the type of change, is as follows: <ol> <li> save the prefix as the user has entered it <li> filter the combo box items against the prefix <li> update the text in the combo box editor with an autocomplete suggestion <li> try to show the popup, if possible </ol>
 */
private void postProcessDocumentChange(FilterBypass filterBypass,AttributeSet attributeSet,String valueBeforeEdit,int selectionStart,int selectionEnd,boolean allowPartialAutoCompletionTerm) throws BadLocationException {
  if (doNotPostProcessDocumentChanges)   return;
  final String valueAfterEdit=comboBoxEditorComponent.getText();
  if (isStrict() && (findAutoCompleteTerm(valueAfterEdit) == NOT_FOUND) && !allItemsUnfiltered.isEmpty()) {
    if (getBeepOnStrictViolation())     UIManager.getLookAndFeel().provideErrorFeedback(comboBoxEditorComponent);
    doNotPostProcessDocumentChanges=true;
    try {
      comboBoxEditorComponent.setText(valueBeforeEdit);
    }
  finally {
      doNotPostProcessDocumentChanges=false;
    }
    comboBoxEditorComponent.select(selectionStart,selectionEnd);
    return;
  }
  final Object selectedItemBeforeEdit=comboBox.getSelectedItem();
  updateFilter();
  applyFilter(prefix);
  selectAutoCompleteTerm(filterBypass,attributeSet,selectedItemBeforeEdit,allowPartialAutoCompletionTerm);
  togglePopup();
}
Program: 32489
Project: 32489
Buggy source:
public void guiTestStrictModeAndFirstItem() throws BadLocationException {
  final JComboBox combo=new JComboBox();
  final EventList<String> items=new BasicEventList<String>();
  items.add("String_Node_Str");
  items.add("String_Node_Str");
  items.add("String_Node_Str");
  items.add("String_Node_Str");
  AutoCompleteSupport support=AutoCompleteSupport.install(combo,items);
  final JTextField textField=(JTextField)combo.getEditor().getEditorComponent();
  assertNull(combo.getSelectedItem());
  support.setStrict(true);
  assertEquals("String_Node_Str",textField.getText());
  support.setStrict(false);
  support.setFirstItem("String_Node_Str");
  combo.setSelectedItem(null);
  assertNull(combo.getSelectedItem());
  support.setStrict(true);
  assertEquals("String_Node_Str",combo.getSelectedItem());
  assertEquals(0,combo.getSelectedIndex());
  support.setStrict(false);
  support.setFirstItem(null);
  combo.setSelectedItem(null);
  assertNull(combo.getSelectedItem());
  assertEquals(-1,combo.getSelectedIndex());
  support.setStrict(true);
  assertNull(combo.getSelectedItem());
  assertEquals(-1,combo.getSelectedIndex());
}

Fixed version (ground truth):
public void guiTestStrictModeAndFirstItem() throws BadLocationException {
  final JComboBox combo=new JComboBox();
  final EventList<String> items=new BasicEventList<String>();
  items.add("String_Node_Str");
  items.add("String_Node_Str");
  items.add("String_Node_Str");
  items.add("String_Node_Str");
  AutoCompleteSupport support=AutoCompleteSupport.install(combo,items);
  final JTextField textField=(JTextField)combo.getEditor().getEditorComponent();
  assertNull(combo.getSelectedItem());
  support.setStrict(true);
  assertEquals("String_Node_Str",textField.getText());
  support.setStrict(false);
  support.setFirstItem("String_Node_Str");
  combo.setSelectedItem(null);
  assertNull(combo.getSelectedItem());
  assertEquals("String_Node_Str",textField.getText());
  support.setStrict(true);
  assertEquals("String_Node_Str",combo.getSelectedItem());
  assertEquals(0,combo.getSelectedIndex());
  assertEquals("String_Node_Str",textField.getText());
  support.setStrict(false);
  support.setFirstItem(null);
  combo.setSelectedItem(null);
  assertNull(combo.getSelectedItem());
  assertEquals(-1,combo.getSelectedIndex());
  support.setStrict(true);
  assertNull(combo.getSelectedItem());
  assertEquals(-1,combo.getSelectedIndex());
  assertEquals("String_Node_Str",textField.getText());
}
Program: 32493
Project: 32493
Buggy source:
/** 
 * Creates a new   {@link EventList} which contains the contents of the specified{@link Collection}. The   {@link EventList}'s order will be determined by  {@link Collection#iterator() contents.iterator()}.
 */
public static <E>EventList<E> eventList(Collection<? extends E> contents){
  final EventList<E> result=new BasicEventList<E>(contents == null ? 0 : contents.size());
  if (contents != null)   result.addAll(contents);
  return result;
}

Fixed version (ground truth):
/** 
 * Creates a new   {@link EventList} with the given {@link ListEventPublisher} and{@link ReadWriteLock} which contains the contents of the specified{@link Collection}. The   {@link EventList}'s order will be determined by  {@link Collection#iterator() contents.iterator()}.
 * @param publisher the {@link ListEventPublisher} for the new list, may be <code>null</code>
 * @param lock the {@link ReadWriteLock} for the new list, may be <code>null</code>
 * @param contents the collection with list elements, if <code>null</code> the result will bean empty list
 */
public static <E>EventList<E> eventList(ListEventPublisher publisher,ReadWriteLock lock,Collection<? extends E> contents){
  final EventList<E> result=new BasicEventList<E>(contents == null ? 0 : contents.size(),publisher,lock);
  if (contents != null)   result.addAll(contents);
  return result;
}
Program: 32494
Project: 32494
Buggy source:
/** 
 * Creates a new   {@link EventList} which contains the given elements.
 */
public static <E>EventList<E> eventListOf(E... contents){
  return eventList(contents == null ? Collections.<E>emptyList() : Arrays.asList(contents));
}

Fixed version (ground truth):
/** 
 * Creates a new   {@link EventList} with the given {@link ListEventPublisher} and{@link ReadWriteLock} which contains the given elements.
 * @param publisher the {@link ListEventPublisher} for the new list, may be <code>null</code>
 * @param lock the {@link ReadWriteLock} for the new list, may be <code>null</code>
 * @param contents the list elements, if <code>null</code> the result will be an empty list
 * @return the new {@link EventList}
 */
public static <E>EventList<E> eventListOf(ListEventPublisher publisher,ReadWriteLock lock,E... contents){
  return eventList(publisher,lock,contents == null ? Collections.<E>emptyList() : Arrays.asList(contents));
}
Program: 32495
Project: 32495
Buggy source:
/** 
 * Test that the   {@link GlazedLists#eventList(java.util.Collection)} factorymethod works.
 * @see <a href="https://glazedlists.dev.java.net/issues/show_bug.cgi?id=234">Bug 234</a>
 */
public void testGlazedListsEventList(){
  List<String> list=new ArrayList<String>();
  EventList<String> eventList=GlazedLists.eventList(list);
  assertEquals(list,eventList);
  list.add("String_Node_Str");
  assertTrue(!list.equals(eventList));
  eventList.add("String_Node_Str");
  assertTrue(!list.equals(eventList));
  EventList<String> empty=GlazedLists.eventList((Collection)null);
  assertEquals(Collections.EMPTY_LIST,empty);
}

Fixed version (ground truth):
/** 
 * Test that the   {@link GlazedLists#eventList(java.util.Collection)} factorymethod works.
 * @see <a href="https://glazedlists.dev.java.net/issues/show_bug.cgi?id=234">Bug 234</a>
 */
public void testGlazedListsEventList(){
  final List<String> list=new ArrayList<String>();
  EventList<String> eventList=GlazedLists.eventList(list);
  assertEquals(list,eventList);
  list.add("String_Node_Str");
  assertTrue(!list.equals(eventList));
  eventList.add("String_Node_Str");
  assertTrue(!list.equals(eventList));
  final EventList<String> empty=GlazedLists.eventList((Collection<String>)null);
  assertEquals(Collections.EMPTY_LIST,empty);
}
Program: 32496
Project: 32496
Buggy source:
/** 
 * Test that the   {@link GlazedLists#eventListOf(Object[])} factorymethod works.
 */
public void testGlazedListsEventListUsingVarArgs(){
  EventList<String> eventList=GlazedLists.eventListOf("String_Node_Str","String_Node_Str");
  assertEquals(Arrays.asList("String_Node_Str","String_Node_Str"),eventList);
  EventList<String> empty=GlazedLists.eventListOf((String[])null);
  assertEquals(Collections.EMPTY_LIST,empty);
}

Fixed version (ground truth):
/** 
 * Test that the   {@link GlazedLists#eventListOf(Object)} factorymethod works.
 */
public void testGlazedListsEventListUsingVarArgs(){
  final EventList<String> eventList=GlazedLists.eventListOf("String_Node_Str","String_Node_Str");
  assertEquals(Arrays.asList("String_Node_Str","String_Node_Str"),eventList);
  final EventList<String> empty=GlazedLists.eventListOf((String[])null);
  assertEquals(Collections.EMPTY_LIST,empty);
}
Program: 32498
Project: 32498
Buggy source:
private void paintGrid(Graphics g,int rMin,int rMax,int cMin,int cMax){
  g.setColor(table.getGridColor());
  Rectangle minCell=table.getCellRect(rMin,cMin,true);
  Rectangle maxCell=table.getCellRect(rMax,cMax,true);
  Rectangle damagedArea=minCell.union(maxCell);
  if (table.getShowHorizontalLines()) {
    int tableWidth=damagedArea.x + damagedArea.width;
    int y=damagedArea.y;
    for (int row=rMin; row <= rMax; row++) {
      y+=table.getRowHeight(row);
      g.drawLine(damagedArea.x,y - 1,tableWidth - 1,y - 1);
    }
  }
  if (table.getShowVerticalLines()) {
    TableColumnModel cm=table.getColumnModel();
    int tableHeight=damagedArea.y + damagedArea.height;
    int x;
    if (table.getComponentOrientation().isLeftToRight()) {
      x=damagedArea.x;
      for (int column=cMin; column <= cMax; column++) {
        x+=cm.getColumn(column).getWidth();
        g.drawLine(x - 1,0,x - 1,tableHeight - 1);
      }
    }
 else {
      x=damagedArea.x + damagedArea.width;
      for (int column=cMin; column < cMax; column++) {
        x-=cm.getColumn(column).getWidth();
        g.drawLine(x - 1,0,x - 1,tableHeight - 1);
      }
      x-=cm.getColumn(cMax).getWidth();
      g.drawLine(x,0,x,tableHeight - 1);
    }
  }
}

Fixed version (ground truth):
private void paintGrid(Graphics g,int rMin,int rMax,int cMin,int cMax){
  g.setColor(table.getGridColor());
  Rectangle minCell=table.getCellRect(rMin,cMin,true);
  Rectangle maxCell=table.getCellRect(rMax,cMax,true);
  Rectangle damagedArea=minCell.union(maxCell);
  if (table.getShowHorizontalLines()) {
    int tableWidth=damagedArea.x + damagedArea.width;
    int y=damagedArea.y;
    for (int row=rMin; row <= rMax; row++) {
      y+=table.getRowHeight(row);
      g.drawLine(damagedArea.x,y - 1,tableWidth - 1,y - 1);
    }
  }
  if (table.getShowVerticalLines()) {
    TableColumnModel cm=table.getColumnModel();
    int tableHeight=damagedArea.y + damagedArea.height;
    int x;
    if (table.getComponentOrientation().isLeftToRight()) {
      x=damagedArea.x;
      for (int column=0; column <= cMax; column++) {
        x+=cm.getColumn(column).getWidth();
        if (column >= cMin)         g.drawLine(x - 1,0,x - 1,tableHeight - 1);
      }
    }
 else {
      x=damagedArea.x + damagedArea.width;
      for (int column=cMin; column < cMax; column++) {
        x-=cm.getColumn(column).getWidth();
        g.drawLine(x - 1,0,x - 1,tableHeight - 1);
      }
      x-=cm.getColumn(cMax).getWidth();
      g.drawLine(x,0,x,tableHeight - 1);
    }
  }
}
Program: 32499
Project: 32499
Buggy source:
/** 
 * Usually, constructors shouldn't supposed to have side-effects, but this one changes the table's filter pipeline. Therefore we use this private constructor and call through it from the   {@link #install} method.
 */
private EventListJXTableSorting(JXTable table,SortedList sortedList){
  this.table=table;
  this.sortedList=sortedList;
  this.originalFilterPipeline=table.getFilters();
  this.sortController=new EventListSortController();
  this.filterPipeline=new EventListFilterPipeline();
  table.setFilters(filterPipeline);
}

Fixed version (ground truth):
/** 
 * Usually, constructors shouldn't supposed to have side-effects, but this one changes the table's filter pipeline. Therefore we use this private constructor and call through it from the   {@link #install} method.
 */
private EventListJXTableSorting(JXTable table,SortedList sortedList,Comparator defaultComparator){
  this.table=table;
  this.sortedList=sortedList;
  this.defaultComparator=defaultComparator;
  this.originalFilterPipeline=table.getFilters();
  this.sortController=new EventListSortController();
  this.filterPipeline=new EventListFilterPipeline();
  table.setFilters(filterPipeline);
}
Program: 32500
Project: 32500
Buggy source:
/** 
 * Remove this   {@link EventListJXTableSorting} from the {@link JXTable}.
 */
public void uninstall(){
  table.setFilters(originalFilterPipeline);
}

Fixed version (ground truth):
/** 
 * Remove this   {@link EventListJXTableSorting} from the {@link JXTable} and restores theoriginal filter pipeline.
 */
public void uninstall(){
  table.setFilters(originalFilterPipeline);
}
Program: 32501
Project: 32501
Buggy source:
/** 
 * Install this   {@link EventListJXTableSorting} to provide the sortingbehaviour for the specified  {@link JXTable}.
 */
public static EventListJXTableSorting install(JXTable table,SortedList sortedList){
  return new EventListJXTableSorting(table,sortedList);
}

Fixed version (ground truth):
/** 
 * Install this   {@link EventListJXTableSorting} to provide the sorting behaviour for thespecified  {@link JXTable}. Optionally, a default comparator can be specified, which is used, when there are no sort keys.
 */
public static EventListJXTableSorting install(JXTable table,SortedList sortedList,Comparator defaultComparator){
  return new EventListJXTableSorting(table,sortedList,defaultComparator);
}
Program: 32502
Project: 32502
Buggy source:
/** 
 * {@inheritDoc} 
 */
public void setSortKeys(List<? extends SortKey> sortKeys){
  if (sortKeys == sortKeysReadOnly)   return;
  if (sortKeys == null)   sortKeys=Collections.emptyList();
  this.sortKeys.clear();
  this.sortKeys.addAll(sortKeys);
  List<Comparator> comparators=new ArrayList<Comparator>(this.sortKeys.size());
  for (int k=0; k < this.sortKeys.size(); k++) {
    SortKey sortKey=this.sortKeys.get(k);
    if (sortKey.getSortOrder() == SortOrder.UNSORTED)     continue;
    Comparator comparator=getComparator(sortKey.getColumn());
    if (sortKey.getSortOrder() == SortOrder.DESCENDING)     comparator=GlazedLists.reverseComparator(comparator);
    comparators.add(comparator);
  }
  final Comparator comparator;
  if (comparators.isEmpty()) {
    comparator=null;
  }
 else   if (comparators.size() == 1) {
    comparator=comparators.get(0);
  }
 else {
    comparator=GlazedLists.chainComparators((List)comparators);
  }
  sortedList.getReadWriteLock().writeLock().lock();
  try {
    sortedList.setComparator(comparator);
  }
  finally {
    sortedList.getReadWriteLock().writeLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public void setSortKeys(List<? extends SortKey> sortKeys){
  if (sortKeys == sortKeysReadOnly)   return;
  if (sortKeys == null)   sortKeys=Collections.emptyList();
  this.sortKeys.clear();
  this.sortKeys.addAll(sortKeys);
  List<Comparator> comparators=new ArrayList<Comparator>(this.sortKeys.size());
  for (int k=0; k < this.sortKeys.size(); k++) {
    SortKey sortKey=this.sortKeys.get(k);
    if (sortKey.getSortOrder() == SortOrder.UNSORTED)     continue;
    Comparator comparator=getComparator(sortKey.getColumn());
    if (sortKey.getSortOrder() == SortOrder.DESCENDING)     comparator=GlazedLists.reverseComparator(comparator);
    comparators.add(comparator);
  }
  final Comparator comparator;
  if (comparators.isEmpty()) {
    comparator=defaultComparator;
  }
 else   if (comparators.size() == 1) {
    comparator=comparators.get(0);
  }
 else {
    comparator=GlazedLists.chainComparators((List)comparators);
  }
  sortedList.getReadWriteLock().writeLock().lock();
  try {
    sortedList.setComparator(comparator);
  }
  finally {
    sortedList.getReadWriteLock().writeLock().unlock();
  }
}
Program: 32503
Project: 32503
Buggy source:
/** 
 * Overridden because AutoCompleteSupport needs absolute control over when a JComboBox's ActionListeners are notified.
 */
public void setSelectedItem(Object selected){
  doNotFilter=true;
  doNotAutoComplete=true;
  final ActionListener[] listeners=unregisterAllActionListeners(comboBox);
  try {
    super.setSelectedItem(selected);
    final int caretPos=comboBoxEditorComponent.getCaretPosition();
    comboBoxEditorComponent.select(caretPos,caretPos);
  }
  finally {
    registerAllActionListeners(comboBox,listeners);
    doNotFilter=false;
    doNotAutoComplete=false;
  }
}

Fixed version (ground truth):
/** 
 * Overridden because AutoCompleteSupport needs absolute control over when a JComboBox's ActionListeners are notified.
 */
public void setSelectedItem(Object selected){
  doNotFilter=true;
  doNotAutoComplete=true;
  final ActionListener[] listeners=unregisterAllActionListeners(comboBox);
  try {
    super.setSelectedItem(selected);
    if (comboBoxEditorComponent != null) {
      final int caretPos=comboBoxEditorComponent.getCaretPosition();
      comboBoxEditorComponent.select(caretPos,caretPos);
    }
  }
  finally {
    registerAllActionListeners(comboBox,listeners);
    doNotFilter=false;
    doNotAutoComplete=false;
  }
}
Program: 32504
Project: 32504
Buggy source:
/** 
 * Gets whether the source   {@link EventList} is writable via this API.<p>Extending classes must override this method in order to make themselves writable.
 */
protected boolean isWritable(){
  return false;
}

Fixed version (ground truth):
/** 
 * Gets whether the source   {@link EventList} is writable via this API.<p>Extending classes must override this method in order to make themselves writable.
 */
protected abstract boolean isWritable();
Program: 32505
Project: 32505
Buggy source:
/** 
 * Test that the ListEvent iterator isn't adjusted by calling  {@link ListEventAssembler#forwardEvent}.
 */
public void testEventStateAfterForwardEvent(){
  EventList<String> source=new BasicEventList<String>();
  CountingList<String> counting=new CountingList<String>(source);
  source.add("String_Node_Str");
  assertEquals(1,counting.changeCount);
}

Fixed version (ground truth):
/** 
 * Test that the ListEvent iterator isn't adjusted by calling  {@link ListEventAssembler#forwardEvent}.
 */
public void testEventStateAfterForwardEvent(){
  EventList<String> source=new BasicEventList<String>();
  ListConsistencyListener lcl=ListConsistencyListener.install(source);
  source.add("String_Node_Str");
  assertEquals(1,lcl.getChangeCount(0));
}
Program: 32506
Project: 32506
Buggy source:
public void testFireChangesAppropriately(){
  final EventList<Number> numbers=new BasicEventList<Number>();
  final DatasetChangeEventCounter counter=new DatasetChangeEventCounter();
  final CalculationCategoryDataset dataset=new CalculationCategoryDataset();
  dataset.addChangeListener(counter);
  assertEquals(0,dataset.getRowCount());
  assertEquals(0,counter.getCountAndReset());
  final Calculation<Integer> intSum=Calculations.sumIntegers(numbers);
  dataset.getCalculations().add(intSum);
  assertEquals(1,dataset.getRowCount());
  assertNull(dataset.getRowKey(0));
  assertEquals(0,dataset.getValue(0,0).intValue());
  assertEquals(1,counter.getCountAndReset());
  numbers.add(2);
  assertEquals(1,dataset.getRowCount());
  assertNull(dataset.getRowKey(0));
  assertEquals(2,dataset.getValue(0,0).intValue());
  assertEquals(1,counter.getCountAndReset());
  intSum.setName("String_Node_Str");
  assertEquals(1,dataset.getRowCount());
  assertEquals("String_Node_Str",dataset.getRowKey(0));
  assertEquals(2,dataset.getValue(0,0).intValue());
  assertEquals(1,counter.getCountAndReset());
  dataset.getCalculations().remove(intSum);
  assertEquals(0,dataset.getRowCount());
  assertEquals(1,counter.getCountAndReset());
}

Fixed version (ground truth):
public void testFireChangesAppropriately(){
  final EventList<Number> numbers=new BasicEventList<Number>();
  final DatasetChangeEventCounter counter=new DatasetChangeEventCounter();
  final CalculationCategoryDataset dataset=new CalculationCategoryDataset();
  dataset.addChangeListener(counter);
  assertEquals(0,dataset.getRowCount());
  assertEquals(0,counter.getCountAndReset());
  final Calculation<Integer> intSum=Calculations.sumIntegers(numbers);
  dataset.getCalculations().add(intSum);
  assertEquals(1,dataset.getRowCount());
  assertNull(dataset.getRowKey(0));
  assertEquals(0,dataset.getValue(0,0).intValue());
  assertEquals(1,counter.getCountAndReset());
  numbers.add(new Integer(2));
  assertEquals(1,dataset.getRowCount());
  assertNull(dataset.getRowKey(0));
  assertEquals(2,dataset.getValue(0,0).intValue());
  assertEquals(1,counter.getCountAndReset());
  intSum.setName("String_Node_Str");
  assertEquals(1,dataset.getRowCount());
  assertEquals("String_Node_Str",dataset.getRowKey(0));
  assertEquals(2,dataset.getValue(0,0).intValue());
  assertEquals(1,counter.getCountAndReset());
  dataset.getCalculations().remove(intSum);
  assertEquals(0,dataset.getRowCount());
  assertEquals(1,counter.getCountAndReset());
}
Program: 32507
Project: 32507
Buggy source:
/** 
 * For implementing the ListEventListener interface. This sends changes to the table which repaints the table cells. Because this class is backed by   {@link GlazedListsSwing#swingThreadProxyList}, all natural calls to this method are guaranteed to occur on the Swing EDT.
 */
public void listChanged(ListEvent<E> listChanges){
  listChanges.nextBlock();
  final int startIndex=listChanges.getBlockStartIndex();
  final int endIndex=listChanges.getBlockEndIndex();
  final int changeType=listChanges.getType();
  tableModelEvent.setValues(startIndex,endIndex,changeType);
  if (listChanges.nextBlock())   tableModelEvent.setAllDataChanged();
  fireTableChanged(tableModelEvent);
}

Fixed version (ground truth):
/** 
 * For implementing the ListEventListener interface. This sends changes to the table which repaints the table cells. Because this class is backed by   {@link GlazedListsSwing#swingThreadProxyList}, all natural calls to this method are guaranteed to occur on the Swing EDT. <p>The translation from the ListEvent to one or more TableModelEvents is affected by property <code>fireOneTableModelEventOnly</code>.</p>
 * @see #setFireOneTableModelEventOnly(boolean)
 */
public void listChanged(ListEvent<E> listChanges){
  if (isFireOneTableModelEventOnly()) {
    fireOneTableModelEvent(listChanges);
  }
 else {
    while (listChanges.nextBlock()) {
      int startIndex=listChanges.getBlockStartIndex();
      int endIndex=listChanges.getBlockEndIndex();
      int changeType=listChanges.getType();
      tableModelEvent.setValues(startIndex,endIndex,changeType);
      fireTableChanged(tableModelEvent);
    }
  }
}
Program: 32508
Project: 32508
Buggy source:
/** 
 * Releases the resources consumed by this   {@link EventTableModel} so that itmay eventually be garbage collected. <p>An  {@link EventTableModel} will be garbage collected without a call to{@link #dispose()}, but not before its source   {@link EventList} is garbagecollected. By calling  {@link #dispose()}, you allow the   {@link EventTableModel}to be garbage collected before its source   {@link EventList}. This is  necessary for situations where an   {@link EventTableModel} is short-lived butits source  {@link EventList} is long-lived.<p><strong><font color="#FF0000">Warning:</font></strong> It is an error to call any method on an  {@link EventTableModel} after it has been disposed.As such, this  {@link EventTableModel} should be detached from itscorresponding Component <strong>before</strong> it is disposed.
 */
public void dispose(){
  source.removeListEventListener(this);
  if (swingThreadSource != null)   swingThreadSource.dispose();
  swingThreadSource=null;
  source=null;
}

Fixed version (ground truth):
/** 
 * Releases the resources consumed by this   {@link EventTableModel} so that itmay eventually be garbage collected. <p>An  {@link EventTableModel} will be garbage collected without a call to{@link #dispose()}, but not before its source   {@link EventList} is garbagecollected. By calling  {@link #dispose()}, you allow the   {@link EventTableModel}to be garbage collected before its source   {@link EventList}. This is necessary for situations where an   {@link EventTableModel} is short-lived butits source  {@link EventList} is long-lived.<p><strong><font color="#FF0000">Warning:</font></strong> It is an error to call any method on an  {@link EventTableModel} after it has been disposed.As such, this  {@link EventTableModel} should be detached from itscorresponding Component <strong>before</strong> it is disposed.
 */
public void dispose(){
  source.removeListEventListener(this);
  if (swingThreadSource != null)   swingThreadSource.dispose();
  swingThreadSource=null;
  source=null;
}
Program: 32509
Project: 32509
Buggy source:
/** 
 * Retrieves the value at the specified location from the table. <p>This may be used by renderers to paint the cells of a row differently based on the entire value for that row. 
 * @see #getValueAt(int,int)
 */
public E getElementAt(int index){
  source.getReadWriteLock().readLock().lock();
  try {
    return source.get(index);
  }
  finally {
    source.getReadWriteLock().readLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * Retrieves the value at the specified location from the table. <p>This may be used by renderers to paint the cells of a row differently based on the entire value for that row.
 * @see #getValueAt(int,int)
 */
public E getElementAt(int index){
  source.getReadWriteLock().readLock().lock();
  try {
    return source.get(index);
  }
  finally {
    source.getReadWriteLock().readLock().unlock();
  }
}
Program: 32511
Project: 32511
Buggy source:
/** 
 * Releases the resources consumed by this   {@link TransformedList} so that itmay eventually be garbage collected. <p>A  {@link TransformedList} will be garbage collected without a call to{@link #dispose()}, but not before its source   {@link EventList} is garbagecollected. By calling  {@link #dispose()}, you allow the   {@link TransformedList}to be garbage collected before its source   {@link EventList}. This is  necessary for situations where a   {@link TransformedList} is short-lived butits source  {@link EventList} is long-lived.<p><strong><font color="#FF0000">Warning:</font></strong> It is an error to call any method on a  {@link TransformedList} after it has been disposed.
 */
public void dispose(){
  source.removeListEventListener(this);
}

Fixed version (ground truth):
/** 
 * Releases the resources consumed by this   {@link TransformedList} so that itmay eventually be garbage collected. <p>A  {@link TransformedList} will be garbage collected without a call to{@link #dispose()}, but not before its source   {@link EventList} is garbagecollected. By calling  {@link #dispose()}, you allow the   {@link TransformedList}to be garbage collected before its source   {@link EventList}. This is necessary for situations where a   {@link TransformedList} is short-lived butits source  {@link EventList} is long-lived.<p><strong><font color="#FF0000">Warning:</font></strong> It is an error to call any method on a  {@link TransformedList} after it has been disposed.
 */
public void dispose(){
  source.removeListEventListener(this);
}
Program: 32512
Project: 32512
Buggy source:
/** 
 * For implementing the ListEventListener interface. This sends changes to the table which repaints the table cells. Because this class is backed by   {@link GlazedListsSwing#swingThreadProxyList}, all natural calls to this method are guaranteed to occur on the Swing EDT. <p>The translation from the ListEvent to one or more TableModelEvents is affected by property <code>fireOneTableModelEventOnly</code>.</p>
 * @see #setFireOneTableModelEventOnly(boolean)
 */
public void listChanged(ListEvent<E> listChanges){
  if (isFireOneTableModelEventOnly() && !listChanges.isReordering()) {
    fireOneTableModelEvent(listChanges);
  }
 else {
    while (listChanges.nextBlock()) {
      int startIndex=listChanges.getBlockStartIndex();
      int endIndex=listChanges.getBlockEndIndex();
      int changeType=listChanges.getType();
      tableModelEvent.setValues(startIndex,endIndex,changeType);
      fireTableChanged(tableModelEvent);
    }
  }
}

Fixed version (ground truth):
/** 
 * For implementing the ListEventListener interface. This sends changes to the table which repaints the table cells. Because this class is backed by   {@link GlazedListsSwing#swingThreadProxyList}, all natural calls to this method are guaranteed to occur on the Swing EDT.
 */
public void listChanged(ListEvent<E> listChanges){
  handleListChange(listChanges);
}
Program: 32513
Project: 32513
Buggy source:
/** 
 * Create a   {@link ThreadProxyEventList} which delivers changes to thegiven <code>source</code> on a particular  {@link Thread}, called the proxy   {@link Thread} of a subclasses choosing. The {@link Thread} useddepends on the implementation of  {@link #schedule(Runnable)}.
 * @param source the {@link EventList} for which to proxy events
 */
public ThreadProxyEventList(EventList<E> source){
  super(source);
  localCache.addAll(source);
  addListEventListener(updateRunner);
  source.addListEventListener(this);
}

Fixed version (ground truth):
/** 
 * Create a   {@link ThreadProxyEventList} which delivers changes to thegiven <code>source</code> on a particular  {@link Thread}, called the proxy   {@link Thread} of a subclasses choosing. The {@link Thread} useddepends on the implementation of  {@link #schedule(Runnable)}.
 * @param source the {@link EventList} for which to proxy events
 */
public ThreadProxyEventList(EventList<E> source){
  super(source);
  localCache.addAll(source);
  cacheUpdates.addListEventListener(updateRunner);
  source.addListEventListener(this);
}
Program: 32514
Project: 32514
Buggy source:
/** 
 * {@inheritDoc} 
 */
public void dispose(){
  super.dispose();
  removeListEventListener(updateRunner);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public void dispose(){
  super.dispose();
  cacheUpdates.removeListEventListener(updateRunner);
}
Program: 32515
Project: 32515
Buggy source:
/** 
 * When run, this combines all events thus far and forwards them. <p>If a reordering event is being forwarded, the reordering may be lost if it arrives simultaneously with another event. This is somewhat of a hack for the time being. Hopefully later we can refine this so that a new event is created with these changes properly.
 */
public void run(){
  getReadWriteLock().writeLock().lock();
  try {
    updates.commitEvent();
    scheduled=false;
  }
  finally {
    getReadWriteLock().writeLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * When run, this combines all events thus far and forwards them. <p>If a reordering event is being forwarded, the reordering may be lost if it arrives simultaneously with another event. This is somewhat of a hack for the time being. Hopefully later we can refine this so that a new event is created with these changes properly.
 */
public void run(){
  getReadWriteLock().writeLock().lock();
  try {
    cacheUpdates.commitEvent();
    updates.commitEvent();
    scheduled=false;
  }
  finally {
    getReadWriteLock().writeLock().unlock();
  }
}
Program: 32517
Project: 32517
Buggy source:
public void run(){
  try {
    final Class guiTestClass=testCase.getClass();
    final Method setUp=guiTestClass.getMethod(SET_UP_METHOD,DECLARE_NO_PARAMETERS);
    final Method tearDown=guiTestClass.getMethod(TEAR_DOWN_METHOD,DECLARE_NO_PARAMETERS);
    final Method[] allMethods=guiTestClass.getMethods();
    for (    Method method : allMethods) {
      final String methodName=method.getName();
      if (methodName.startsWith(JUNIT_BAD_PREFIX) && !methodName.equals(JUNIT_OK_METHOD))       throw new IllegalStateException(methodName + "String_Node_Str" + methodName.substring(1)+ "String_Node_Str");
    }
    for (    Method method : allMethods) {
      if (!method.getName().startsWith(TEST_METHOD_PREFIX))       continue;
      System.out.println("String_Node_Str" + method.getName());
      setUp.invoke(testCase,SEND_NO_PARAMETERS);
      method.invoke(testCase,SEND_NO_PARAMETERS);
      tearDown.invoke(testCase,SEND_NO_PARAMETERS);
    }
  }
 catch (  InvocationTargetException e) {
    throw new RuntimeException(e.getCause());
  }
catch (  NoSuchMethodException e) {
    throw new RuntimeException(e);
  }
catch (  IllegalAccessException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public void run(){
  try {
    final Class guiTestClass=testCase.getClass();
    final Method setUp=guiTestClass.getMethod(SET_UP_METHOD,DECLARE_NO_PARAMETERS);
    final Method tearDown=guiTestClass.getMethod(TEAR_DOWN_METHOD,DECLARE_NO_PARAMETERS);
    final Method[] allMethods=guiTestClass.getMethods();
    for (int i=0; i < allMethods.length; i++) {
      final String methodName=allMethods[i].getName();
      if (methodName.startsWith(JUNIT_BAD_PREFIX) && !methodName.equals(JUNIT_OK_METHOD))       throw new IllegalStateException(methodName + "String_Node_Str" + methodName.substring(1)+ "String_Node_Str");
    }
    for (int i=0; i < allMethods.length; i++) {
      final String methodName=allMethods[i].getName();
      if (!methodName.startsWith(TEST_METHOD_PREFIX))       continue;
      System.out.println("String_Node_Str" + methodName);
      setUp.invoke(testCase,SEND_NO_PARAMETERS);
      allMethods[i].invoke(testCase,SEND_NO_PARAMETERS);
      tearDown.invoke(testCase,SEND_NO_PARAMETERS);
    }
  }
 catch (  InvocationTargetException e) {
    throw new RuntimeException(e.getCause());
  }
catch (  NoSuchMethodException e) {
    throw new RuntimeException(e);
  }
catch (  IllegalAccessException e) {
    throw new RuntimeException(e);
  }
}
Program: 32520
Project: 32520
Buggy source:
public boolean matches(E item){
  if (item == null)   return false;
  final Class target=item.getClass();
  for (  Class clazz : classes)   if (clazz.isAssignableFrom(target))   return true;
  return false;
}

Fixed version (ground truth):
public boolean matches(E item){
  if (item == null)   return false;
  final Class target=item.getClass();
  for (int i=0; i < classes.length; i++)   if (classes[i].isAssignableFrom(target))   return true;
  return false;
}
Program: 32521
Project: 32521
Buggy source:
/** 
 * Convert an array of Strings into a List of characters.
 */
public static List<String> stringsToList(CharSequence[] data){
  List<String> result=new ArrayList<String>();
  for (  CharSequence datum : data)   result.addAll(stringToList(datum));
  return result;
}

Fixed version (ground truth):
/** 
 * Convert an array of Strings into a List of characters.
 */
public static List<String> stringsToList(CharSequence[] data){
  List<String> result=new ArrayList<String>();
  for (int i=0; i < data.length; i++)   result.addAll(stringToList(data[i]));
  return result;
}
Program: 32522
Project: 32522
Buggy source:
/** 
 * Convert the specified int[] array to a List of Integers.
 */
public static List<Integer> intArrayToIntegerCollection(int[] values){
  List<Integer> result=new ArrayList<Integer>();
  for (  int value : values)   result.add(new Integer(value));
  return result;
}

Fixed version (ground truth):
/** 
 * Convert the specified int[] array to a List of Integers.
 */
public static List<Integer> intArrayToIntegerCollection(int[] values){
  List<Integer> result=new ArrayList<Integer>();
  for (int i=0; i < values.length; i++)   result.add(new Integer(values[i]));
  return result;
}
Program: 32523
Project: 32523
Buggy source:
/** 
 * Convert a String like "AA,BB,CDE" into three Lists: { [ A A ], [ B B ], [ C D E ] }
 */
public static List<List<String>> stringToLists(CharSequence chars){
  List<List<String>> result=new ArrayList<List<String>>();
  String[] strings=chars.toString().split("String_Node_Str");
  for (  String string : strings)   result.add(stringToList(string));
  return result;
}

Fixed version (ground truth):
/** 
 * Convert a String like "AA,BB,CDE" into three Lists: { [ A A ], [ B B ], [ C D E ] }
 */
public static List<List<String>> stringToLists(CharSequence chars){
  List<List<String>> result=new ArrayList<List<String>>();
  String[] strings=chars.toString().split("String_Node_Str");
  for (int i=0; i < strings.length; i++)   result.add(stringToList(strings[i]));
  return result;
}
Program: 32524
Project: 32524
Buggy source:
public void testTypeMatcher(){
  final List<Number> numbers=new ArrayList<Number>();
  numbers.add(new Float(0));
  numbers.add(new Double(1));
  numbers.add(new Short((short)2));
  numbers.add(new Integer(3));
  numbers.add(new Long(4));
  Collection<? super Number> selected;
  final Matcher<Number> intAndLongMatcher=Matchers.types(Long.class,Integer.class);
  selected=Matchers.select(numbers,intAndLongMatcher);
  assertEquals(Arrays.asList(new Integer(3),new Long(4)),selected);
  final Matcher<Number> numberMatcher=Matchers.types(Number.class);
  selected=Matchers.select(numbers,numberMatcher);
  assertEquals(Arrays.asList(new Float(0),new Double(1),new Short((short)2),new Integer(3),new Long(4)),selected);
  final Matcher<Number> stringMatcher=Matchers.types(String.class);
  selected=Matchers.select(numbers,stringMatcher);
  assertEquals(Collections.EMPTY_LIST,selected);
}

Fixed version (ground truth):
public void testTypeMatcher(){
  final List<Number> numbers=new ArrayList<Number>();
  numbers.add(new Float(0));
  numbers.add(new Double(1));
  numbers.add(new Short((short)2));
  numbers.add(new Integer(3));
  numbers.add(new Long(4));
  Collection<? super Number> selected;
  final Matcher<Number> intAndLongMatcher=Matchers.types(new Class[]{Long.class,Integer.class});
  selected=Matchers.select(numbers,intAndLongMatcher);
  assertEquals(Arrays.asList(new Number[]{new Integer(3),new Long(4)}),selected);
  final Matcher<Number> numberMatcher=Matchers.types(new Class[]{Number.class});
  selected=Matchers.select(numbers,numberMatcher);
  assertEquals(Arrays.asList(new Number[]{new Float(0),new Double(1),new Short((short)2),new Integer(3),new Long(4)}),selected);
  final Matcher<Number> stringMatcher=Matchers.types(new Class[]{String.class});
  selected=Matchers.select(numbers,stringMatcher);
  assertEquals(Collections.EMPTY_LIST,selected);
}
Program: 32529
Project: 32529
Buggy source:
/** 
 * Tests that comparison by property works.
 */
public void testCompare(){
  Comparator comparator=GlazedLists.beanPropertyComparator(Position.class,"String_Node_Str");
  assertTrue(comparator.compare(new Position(4),new Position(1)) > 0);
  assertTrue(comparator.compare(new Position(1),new Position(4)) < 0);
  assertTrue(comparator.compare(new Position(3),new Position(3)) == 0);
}

Fixed version (ground truth):
/** 
 * Tests that comparison by property works.
 */
public void testCompare(){
  Comparator comparator=GlazedLists.beanPropertyComparator(Position.class,"String_Node_Str",new String[0]);
  assertTrue(comparator.compare(new Position(4),new Position(1)) > 0);
  assertTrue(comparator.compare(new Position(1),new Position(4)) < 0);
  assertTrue(comparator.compare(new Position(3),new Position(3)) == 0);
}
Program: 32530
Project: 32530
Buggy source:
/** 
 * Tests that comparison by property works.
 */
public void testSort(){
  List unsorted=new ArrayList();
  unsorted.add(new Position(4));
  unsorted.add(new Position(1));
  unsorted.add(new Position(3));
  List sorted1=new ArrayList();
  sorted1.addAll(unsorted);
  Collections.sort(sorted1);
  List sorted2=new ArrayList();
  sorted2.addAll(unsorted);
  Collections.sort(sorted2,GlazedLists.beanPropertyComparator(Position.class,"String_Node_Str"));
  assertEquals(sorted1,sorted2);
}

Fixed version (ground truth):
/** 
 * Tests that comparison by property works.
 */
public void testSort(){
  List unsorted=new ArrayList();
  unsorted.add(new Position(4));
  unsorted.add(new Position(1));
  unsorted.add(new Position(3));
  List sorted1=new ArrayList();
  sorted1.addAll(unsorted);
  Collections.sort(sorted1);
  List sorted2=new ArrayList();
  sorted2.addAll(unsorted);
  Collections.sort(sorted2,GlazedLists.beanPropertyComparator(Position.class,"String_Node_Str",new String[0]));
  assertEquals(sorted1,sorted2);
}
Program: 32531
Project: 32531
Buggy source:
/** 
 * Tests that the equals() method of the comparator works.
 */
public void testEquals(){
  Comparator red=GlazedLists.beanPropertyComparator(Color.class,"String_Node_Str");
  Comparator blue=GlazedLists.beanPropertyComparator(Color.class,"String_Node_Str");
  Comparator rouge=GlazedLists.beanPropertyComparator(Color.class,"String_Node_Str");
  Comparator blueBeer=GlazedLists.beanPropertyComparator(LabattBeer.class,"String_Node_Str");
  assertTrue(red.equals(rouge));
  assertFalse(blue.equals(blueBeer));
  assertFalse(red.equals(blue));
}

Fixed version (ground truth):
/** 
 * Tests that the equals() method of the comparator works.
 */
public void testEquals(){
  final String[] empty={};
  Comparator red=GlazedLists.beanPropertyComparator(Color.class,"String_Node_Str",empty);
  Comparator blue=GlazedLists.beanPropertyComparator(Color.class,"String_Node_Str",empty);
  Comparator rouge=GlazedLists.beanPropertyComparator(Color.class,"String_Node_Str",empty);
  Comparator blueBeer=GlazedLists.beanPropertyComparator(LabattBeer.class,"String_Node_Str",empty);
  assertTrue(red.equals(rouge));
  assertFalse(blue.equals(blueBeer));
  assertFalse(red.equals(blue));
}
Program: 32532
Project: 32532
Buggy source:
public void guiTestSetValueAt_SortedList(){
  final EventList<JLabel> labels=new BasicEventList<JLabel>();
  labels.add(new JLabel("String_Node_Str"));
  labels.add(new JLabel("String_Node_Str"));
  labels.add(new JLabel("String_Node_Str"));
  final ObservableElementList<JLabel> observedLabels=new ObservableElementList<JLabel>(labels,GlazedLists.beanConnector(JLabel.class));
  final SortedList<JLabel> sortedLabels=new SortedList<JLabel>(observedLabels,GlazedLists.beanPropertyComparator(JLabel.class,"String_Node_Str"));
  final EventTableModel<JLabel> tableModel=new EventTableModel<JLabel>(sortedLabels,new LabelTableFormat());
  assertEquals(3,tableModel.getRowCount());
  assertEquals("String_Node_Str",tableModel.getValueAt(0,0));
  assertEquals("String_Node_Str",tableModel.getValueAt(1,0));
  assertEquals("String_Node_Str",tableModel.getValueAt(2,0));
  tableModel.setValueAt("String_Node_Str",1,0);
  assertEquals(3,tableModel.getRowCount());
  assertEquals("String_Node_Str",tableModel.getValueAt(0,0));
  assertEquals("String_Node_Str",tableModel.getValueAt(1,0));
  assertEquals("String_Node_Str",tableModel.getValueAt(2,0));
}

Fixed version (ground truth):
public void guiTestSetValueAt_SortedList(){
  final EventList<JLabel> labels=new BasicEventList<JLabel>();
  labels.add(new JLabel("String_Node_Str"));
  labels.add(new JLabel("String_Node_Str"));
  labels.add(new JLabel("String_Node_Str"));
  final ObservableElementList<JLabel> observedLabels=new ObservableElementList<JLabel>(labels,GlazedLists.beanConnector(JLabel.class));
  final SortedList<JLabel> sortedLabels=new SortedList<JLabel>(observedLabels,GlazedLists.beanPropertyComparator(JLabel.class,"String_Node_Str",new String[0]));
  final EventTableModel<JLabel> tableModel=new EventTableModel<JLabel>(sortedLabels,new LabelTableFormat());
  assertEquals(3,tableModel.getRowCount());
  assertEquals("String_Node_Str",tableModel.getValueAt(0,0));
  assertEquals("String_Node_Str",tableModel.getValueAt(1,0));
  assertEquals("String_Node_Str",tableModel.getValueAt(2,0));
  tableModel.setValueAt("String_Node_Str",1,0);
  assertEquals(3,tableModel.getRowCount());
  assertEquals("String_Node_Str",tableModel.getValueAt(0,0));
  assertEquals("String_Node_Str",tableModel.getValueAt(1,0));
  assertEquals("String_Node_Str",tableModel.getValueAt(2,0));
}
Program: 32533
Project: 32533
Buggy source:
/** 
 * Verifies that the selected index is cleared when the selection is cleared.
 */
public void guiTestClear(){
  EventList<String> list=new BasicEventList<String>();
  EventSelectionModel eventSelectionModel=new EventSelectionModel<String>(list);
  list.addAll(GlazedListsTests.delimitedStringToList("String_Node_Str"));
  eventSelectionModel.addSelectionInterval(1,4);
  assertEquals(list.subList(1,5),eventSelectionModel.getSelected());
  eventSelectionModel.clearSelection();
  assertEquals(Collections.EMPTY_LIST,eventSelectionModel.getSelected());
  assertEquals(-1,eventSelectionModel.getMinSelectionIndex());
  assertEquals(-1,eventSelectionModel.getMaxSelectionIndex());
  assertEquals(true,eventSelectionModel.isSelectionEmpty());
}

Fixed version (ground truth):
/** 
 * Verifies that the selected index is cleared when the selection is cleared.
 */
public void guiTestClear(){
  EventList<String> list=new BasicEventList<String>();
  EventSelectionModel eventSelectionModel=new EventSelectionModel<String>(list);
  list.addAll(GlazedListsTests.delimitedStringToList("String_Node_Str"));
  eventSelectionModel.addSelectionInterval(1,4);
  assertEquals(list.subList(1,5),eventSelectionModel.getSelected());
  assertEquals(list.subList(1,5),eventSelectionModel.getTogglingSelected());
  assertEquals(GlazedListsTests.delimitedStringToList("String_Node_Str"),eventSelectionModel.getDeselected());
  assertEquals(GlazedListsTests.delimitedStringToList("String_Node_Str"),eventSelectionModel.getTogglingDeselected());
  eventSelectionModel.clearSelection();
  assertEquals(Collections.EMPTY_LIST,eventSelectionModel.getSelected());
  assertEquals(Collections.EMPTY_LIST,eventSelectionModel.getTogglingSelected());
  assertEquals(-1,eventSelectionModel.getMinSelectionIndex());
  assertEquals(-1,eventSelectionModel.getMaxSelectionIndex());
  assertEquals(true,eventSelectionModel.isSelectionEmpty());
  assertEquals(list,eventSelectionModel.getDeselected());
  assertEquals(list,eventSelectionModel.getTogglingDeselected());
}
Program: 32535
Project: 32535
Buggy source:
/** 
 * Updates the comparator in use and applies it to the table.
 */
protected final void rebuildComparator(){
  super.rebuildComparator();
  Event sortEvent=new Event();
  sortEvent.widget=table;
  for (Iterator<Listener> i=sortListeners.iterator(); i.hasNext(); ) {
    i.next().handleEvent(sortEvent);
  }
}

Fixed version (ground truth):
/** 
 * Updates the comparator in use and applies it to the table. <p>This method is called when the sorting state changed.</p>
 */
protected final void rebuildComparator(){
  super.rebuildComparator();
  updateTableSortColumn();
  Event sortEvent=new Event();
  sortEvent.widget=table;
  for (Iterator<Listener> i=sortListeners.iterator(); i.hasNext(); ) {
    i.next().handleEvent(sortEvent);
  }
}