Program: 32488
Project: 32488
Buggy source:
/** 
 * When the data under a strict-mode AutoCompleting JComboBox is changed we must recheck the strict-mode invariant that the filter text matches (at least partially) an element in the ComboBoxModel. This test case verifies that the invariant is maintained while data changes underneath.
 */
public void testOnMainThreadChangingComboBoxDataRetainsStrictModeInvariant() throws Exception {
  final JComboBox combo=new JComboBox();
  final JTextField textField=(JTextField)combo.getEditor().getEditorComponent();
  final EventList<String> items=new BasicEventList<String>();
  items.add("String_Node_Str");
  SwingUtilities.invokeAndWait(new Runnable(){
    public void run(){
      final AutoCompleteSupport support=AutoCompleteSupport.install(combo,items);
      support.setStrict(true);
    }
  }
);
  assertEquals("String_Node_Str",textField.getText());
  assertEquals("String_Node_Str",combo.getSelectedItem());
  items.add("String_Node_Str");
  Thread.sleep(250);
  assertEquals("String_Node_Str",textField.getText());
  assertEquals("String_Node_Str",combo.getSelectedItem());
  items.set(1,"String_Node_Str");
  Thread.sleep(250);
  assertEquals("String_Node_Str",textField.getText());
  assertEquals("String_Node_Str",combo.getSelectedItem());
  items.remove(1);
  Thread.sleep(250);
  assertEquals("String_Node_Str",textField.getText());
  assertEquals("String_Node_Str",combo.getSelectedItem());
  items.set(0,"String_Node_Str");
  Thread.sleep(250);
  assertEquals("String_Node_Str",textField.getText());
  assertEquals("String_Node_Str",combo.getSelectedItem());
}

Fixed version (ground truth):
/** 
 * When the data under a strict-mode AutoCompleting JComboBox is changed we must recheck the strict-mode invariant that the filter text matches (at least partially) an element in the ComboBoxModel. This test case verifies that the invariant is maintained while data changes underneath.
 */
public void testOnMainThreadChangingComboBoxDataRetainsStrictModeInvariant() throws Exception {
  final JComboBox combo=new JComboBox();
  final JTextField textField=(JTextField)combo.getEditor().getEditorComponent();
  final EventList<String> basicItems=new BasicEventList<String>();
  final EventList<String> items=GlazedLists.threadSafeList(basicItems);
  items.add("String_Node_Str");
  SwingUtilities.invokeAndWait(new Runnable(){
    public void run(){
      final AutoCompleteSupport support=AutoCompleteSupport.install(combo,items);
      support.setStrict(true);
    }
  }
);
  assertEquals("String_Node_Str",textField.getText());
  assertEquals("String_Node_Str",combo.getSelectedItem());
  items.add("String_Node_Str");
  Thread.sleep(250);
  assertEquals("String_Node_Str",textField.getText());
  assertEquals("String_Node_Str",combo.getSelectedItem());
  items.set(1,"String_Node_Str");
  Thread.sleep(250);
  assertEquals("String_Node_Str",textField.getText());
  assertEquals("String_Node_Str",combo.getSelectedItem());
  items.remove(1);
  Thread.sleep(250);
  assertEquals("String_Node_Str",textField.getText());
  assertEquals("String_Node_Str",combo.getSelectedItem());
  items.set(0,"String_Node_Str");
  Thread.sleep(250);
  assertEquals("String_Node_Str",textField.getText());
  assertEquals("String_Node_Str",combo.getSelectedItem());
}