Program: 32830
Project: 32830
Buggy source:
/** 
 * Set the comparator used to sort this list. This will resort the list and will take <code>O(N * Log N)</code> time. For large lists, it may be worthwhile to create multiple SortedList views, each of which uses a different Comparator to specify the ordering.
 * @param comparator the comparator to specify how to sort the list. Ifthe list elements implement <code>Comparable</code>, you may use a <code>ComparableComparator</code> instance to sort them in their natural order. You may also specify <code>null</code>, which will leave the list in the same order as the source list.
 */
public void setComparator(Comparator comparator){
  ((InternalReadWriteLock)getReadWriteLock()).internalLock().lock();
  try {
    this.comparator=comparator;
    IndexedTree previousSorted=sorted;
    IndexedTree previousUnsorted=unsorted;
    Comparator treeComparator=null;
    if (comparator != null)     treeComparator=new IndexedTreeNodeComparator(comparator);
 else     treeComparator=new IndexedTreeNodeRawOrderComparator();
    sorted=new IndexedTree(treeComparator);
    unsorted=new IndexedTree();
    for (int i=0; i < source.size(); i++) {
      IndexedTreeNode unsortedNode=unsorted.addByNode(i,this);
      insertByUnsortedNode(unsortedNode);
    }
    if (previousSorted == null && previousUnsorted == null)     return;
    int[] reorderMap=new int[size()];
    for (int i=0; i < reorderMap.length; i++) {
      IndexedTreeNode sortedNode=sorted.getNode(i);
      IndexedTreeNode unsortedNode=(IndexedTreeNode)sortedNode.getValue();
      int unsortedIndex=unsortedNode.getIndex();
      IndexedTreeNode previousUnsortedNode=previousUnsorted.getNode(unsortedIndex);
      IndexedTreeNode previousSortedNode=(IndexedTreeNode)previousUnsortedNode.getValue();
      int previousIndex=previousSortedNode.getIndex();
      reorderMap[i]=previousIndex;
    }
    updates.beginEvent();
    updates.reorder(reorderMap);
    updates.commitEvent();
  }
  finally {
    ((InternalReadWriteLock)getReadWriteLock()).internalLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * Set the comparator used to sort this list. This will resort the list and will take <code>O(N * Log N)</code> time. For large lists, it may be worthwhile to create multiple SortedList views, each of which uses a different Comparator to specify the ordering.
 * @param comparator the comparator to specify how to sort the list. Ifthe list elements implement <code>Comparable</code>, you may use a <code>ComparableComparator</code> instance to sort them in their natural order. You may also specify <code>null</code>, which will leave the list in the same order as the source list.
 */
public void setComparator(Comparator comparator){
  ((InternalReadWriteLock)getReadWriteLock()).internalLock().lock();
  try {
    this.comparator=comparator;
    IndexedTree previousSorted=sorted;
    IndexedTree previousUnsorted=unsorted;
    Comparator treeComparator=null;
    if (comparator != null)     treeComparator=new IndexedTreeNodeComparator(comparator);
 else     treeComparator=new IndexedTreeNodeRawOrderComparator();
    sorted=new IndexedTree(treeComparator);
    unsorted=new IndexedTree();
    if (source.size() == 0)     return;
    for (int i=0; i < source.size(); i++) {
      IndexedTreeNode unsortedNode=unsorted.addByNode(i,this);
      insertByUnsortedNode(unsortedNode);
    }
    if (previousSorted == null && previousUnsorted == null)     return;
    int[] reorderMap=new int[size()];
    for (int i=0; i < reorderMap.length; i++) {
      IndexedTreeNode sortedNode=sorted.getNode(i);
      IndexedTreeNode unsortedNode=(IndexedTreeNode)sortedNode.getValue();
      int unsortedIndex=unsortedNode.getIndex();
      IndexedTreeNode previousUnsortedNode=previousUnsorted.getNode(unsortedIndex);
      IndexedTreeNode previousSortedNode=(IndexedTreeNode)previousUnsortedNode.getValue();
      int previousIndex=previousSortedNode.getIndex();
      reorderMap[i]=previousIndex;
    }
    updates.beginEvent();
    updates.reorder(reorderMap);
    updates.commitEvent();
  }
  finally {
    ((InternalReadWriteLock)getReadWriteLock()).internalLock().unlock();
  }
}