Program: 32786
Project: 32786
Buggy source:
/** 
 * For implementing the ListEventListener interface. When the underlying list changes, this notification allows the object to repaint itself or update itself as necessary.
 */
public void listChanged(ListEvent listChanges){
  if (listChanges.isReordering()) {
    int[] reorderMap=listChanges.getReorderMap();
    IndexedTreeNode[] sortedNodes=new IndexedTreeNode[sorted.size()];
    int index=0;
    for (Iterator i=unsorted.iterator(); i.hasNext(); index++) {
      IndexedTreeNode unsortedNode=(IndexedTreeNode)i.next();
      IndexedTreeNode sortedNode=(IndexedTreeNode)unsortedNode.getValue();
      sortedNodes[index]=sortedNode;
    }
    index=0;
    for (Iterator i=unsorted.iterator(); i.hasNext(); index++) {
      IndexedTreeNode unsortedNode=(IndexedTreeNode)i.next();
      unsortedNode.setValue(sortedNodes[reorderMap[index]]);
      sortedNodes[reorderMap[index]].setValue(unsortedNode);
    }
    return;
  }
  updates.beginEvent();
  LinkedList insertNodes=new LinkedList();
  ListEvent firstPass=new ListEvent(listChanges);
  while (firstPass.next()) {
    int unsortedIndex=firstPass.getIndex();
    int changeType=firstPass.getType();
    if (changeType == ListEvent.INSERT) {
      IndexedTreeNode unsortedNode=unsorted.addByNode(unsortedIndex,this);
      insertNodes.addLast(unsortedNode);
    }
 else     if (changeType == ListEvent.DELETE) {
      IndexedTreeNode unsortedNode=unsorted.getNode(unsortedIndex);
      unsortedNode.removeFromTree();
      int deleteSortedIndex=deleteByUnsortedNode(unsortedNode);
      updates.addDelete(deleteSortedIndex);
    }
 else     if (changeType == ListEvent.UPDATE) {
    }
  }
  IndicesPendingDeletion indicesPendingDeletion=new IndicesPendingDeletion();
  ListEvent secondPass=new ListEvent(listChanges);
  while (secondPass.next()) {
    int unsortedIndex=secondPass.getIndex();
    int changeType=secondPass.getType();
    if (changeType == ListEvent.UPDATE) {
      IndexedTreeNode unsortedNode=unsorted.getNode(unsortedIndex);
      IndexedTreeNode sortedNode=(IndexedTreeNode)unsortedNode.getValue();
      int originalIndex=sortedNode.getIndex();
      indicesPendingDeletion.addPair(new IndexNodePair(originalIndex,unsortedNode));
    }
  }
  ListEvent thirdPass=listChanges;
  while (thirdPass.next()) {
    int unsortedIndex=thirdPass.getIndex();
    int changeType=thirdPass.getType();
    if (changeType == ListEvent.UPDATE) {
      IndexedTreeNode unsortedNode=unsorted.getNode(unsortedIndex);
      int deleteSortedIndex=deleteByUnsortedNode(unsortedNode);
    }
  }
  while (indicesPendingDeletion.hasPair()) {
    IndexNodePair indexNodePair=indicesPendingDeletion.removePair();
    int insertedIndex=insertByUnsortedNode(indexNodePair.node);
    int deletedIndex=indexNodePair.index;
    insertedIndex=indicesPendingDeletion.adjustDeleteAndInsert(deletedIndex,insertedIndex);
    if (deletedIndex == insertedIndex) {
      updates.addUpdate(insertedIndex);
    }
 else {
      updates.addDelete(deletedIndex);
      updates.addInsert(insertedIndex);
    }
  }
  while (!insertNodes.isEmpty()) {
    IndexedTreeNode insertNode=(IndexedTreeNode)insertNodes.removeFirst();
    int insertedIndex=insertByUnsortedNode(insertNode);
    updates.addInsert(insertedIndex);
  }
  updates.commitEvent();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public void listChanged(ListEvent listChanges){
  if (listChanges.isReordering()) {
    int[] reorderMap=listChanges.getReorderMap();
    IndexedTreeNode[] sortedNodes=new IndexedTreeNode[sorted.size()];
    int index=0;
    for (Iterator i=unsorted.iterator(); i.hasNext(); index++) {
      IndexedTreeNode unsortedNode=(IndexedTreeNode)i.next();
      IndexedTreeNode sortedNode=(IndexedTreeNode)unsortedNode.getValue();
      sortedNodes[index]=sortedNode;
    }
    index=0;
    for (Iterator i=unsorted.iterator(); i.hasNext(); index++) {
      IndexedTreeNode unsortedNode=(IndexedTreeNode)i.next();
      unsortedNode.setValue(sortedNodes[reorderMap[index]]);
      sortedNodes[reorderMap[index]].setValue(unsortedNode);
    }
    return;
  }
  updates.beginEvent();
  LinkedList insertNodes=new LinkedList();
  ListEvent firstPass=new ListEvent(listChanges);
  while (firstPass.next()) {
    int unsortedIndex=firstPass.getIndex();
    int changeType=firstPass.getType();
    if (changeType == ListEvent.INSERT) {
      IndexedTreeNode unsortedNode=unsorted.addByNode(unsortedIndex,this);
      insertNodes.addLast(unsortedNode);
    }
 else     if (changeType == ListEvent.DELETE) {
      IndexedTreeNode unsortedNode=unsorted.getNode(unsortedIndex);
      unsortedNode.removeFromTree();
      int deleteSortedIndex=deleteByUnsortedNode(unsortedNode);
      updates.addDelete(deleteSortedIndex);
    }
 else     if (changeType == ListEvent.UPDATE) {
    }
  }
  IndicesPendingDeletion indicesPendingDeletion=new IndicesPendingDeletion();
  ListEvent secondPass=new ListEvent(listChanges);
  while (secondPass.next()) {
    int unsortedIndex=secondPass.getIndex();
    int changeType=secondPass.getType();
    if (changeType == ListEvent.UPDATE) {
      IndexedTreeNode unsortedNode=unsorted.getNode(unsortedIndex);
      IndexedTreeNode sortedNode=(IndexedTreeNode)unsortedNode.getValue();
      int originalIndex=sortedNode.getIndex();
      indicesPendingDeletion.addPair(new IndexNodePair(originalIndex,unsortedNode));
    }
  }
  ListEvent thirdPass=listChanges;
  while (thirdPass.next()) {
    int unsortedIndex=thirdPass.getIndex();
    int changeType=thirdPass.getType();
    if (changeType == ListEvent.UPDATE) {
      IndexedTreeNode unsortedNode=unsorted.getNode(unsortedIndex);
      int deleteSortedIndex=deleteByUnsortedNode(unsortedNode);
    }
  }
  while (indicesPendingDeletion.hasPair()) {
    IndexNodePair indexNodePair=indicesPendingDeletion.removePair();
    int insertedIndex=insertByUnsortedNode(indexNodePair.node);
    int deletedIndex=indexNodePair.index;
    insertedIndex=indicesPendingDeletion.adjustDeleteAndInsert(deletedIndex,insertedIndex);
    if (deletedIndex == insertedIndex) {
      updates.addUpdate(insertedIndex);
    }
 else {
      updates.addDelete(deletedIndex);
      updates.addInsert(insertedIndex);
    }
  }
  while (!insertNodes.isEmpty()) {
    IndexedTreeNode insertNode=(IndexedTreeNode)insertNodes.removeFirst();
    int insertedIndex=insertByUnsortedNode(insertNode);
    updates.addInsert(insertedIndex);
  }
  updates.commitEvent();
}