Program: 32819
Project: 32819
Buggy source:
/** 
 * Notifies this SelectionList about changes to its underlying list store. This changes the flag list. Changes to the source list may cause simultaneous changes to the corresponding selection list.
 */
public void listChanged(ListEvent listChanges){
  int minSelectionIndexBefore=selectionModel.getMinSelectionIndex();
  int maxSelectionIndexBefore=selectionModel.getMaxSelectionIndex();
  updates.beginEvent();
  if (listChanges.isReordering()) {
    int[] sourceReorderMap=listChanges.getReorderMap();
    int[] selectReorderMap=new int[flagList.getCompressedList().size()];
    SparseList previousFlagList=flagList;
    flagList=new SparseList();
    for (int c=0; c < sourceReorderMap.length; c++) {
      Object flag=previousFlagList.get(sourceReorderMap[c]);
      boolean wasSelected=(flag != null);
      flagList.add(c,flag);
      if (wasSelected) {
        int previousIndex=previousFlagList.getCompressedIndex(sourceReorderMap[c]);
        int currentIndex=flagList.getCompressedIndex(c);
        selectReorderMap[currentIndex]=previousIndex;
      }
    }
    updates.reorder(selectReorderMap);
  }
 else {
    while (listChanges.next()) {
      int index=listChanges.getIndex();
      int changeType=listChanges.getType();
      boolean previouslySelected=(flagList.size() > index) && (flagList.get(index) != null);
      int previousSelectionIndex=-1;
      if (previouslySelected)       previousSelectionIndex=flagList.getCompressedIndex(index);
      if (changeType == ListEvent.DELETE) {
        flagList.remove(index);
        if (previouslySelected) {
          updates.addDelete(previousSelectionIndex);
        }
      }
 else       if (changeType == ListEvent.INSERT) {
        if (previouslySelected) {
          if (selectionModel.selectionMode == selectionModel.SINGLE_INTERVAL_SELECTION || selectionModel.selectionMode == selectionModel.MULTIPLE_INTERVAL_SELECTION) {
            flagList.add(index,Boolean.TRUE);
            updates.addInsert(previousSelectionIndex);
          }
 else {
            flagList.add(index,null);
          }
        }
 else {
          flagList.add(index,null);
        }
      }
 else       if (changeType == ListEvent.UPDATE) {
        if (previouslySelected) {
          updates.addUpdate(previousSelectionIndex);
        }
      }
    }
  }
  updates.commitEvent();
  if (minSelectionIndexBefore != 0 && maxSelectionIndexBefore != 0) {
    int minSelectionIndexAfter=selectionModel.getMinSelectionIndex();
    int maxSelectionIndexAfter=selectionModel.getMaxSelectionIndex();
    int changeStart=minSelectionIndexBefore;
    int changeFinish=maxSelectionIndexBefore;
    if (minSelectionIndexAfter != -1 && minSelectionIndexAfter < changeStart)     changeStart=minSelectionIndexAfter;
    if (maxSelectionIndexAfter != -1 && maxSelectionIndexAfter > changeFinish)     changeFinish=maxSelectionIndexAfter;
    selectionModel.fireSelectionChanged(changeStart,changeFinish);
  }
}

Fixed version (ground truth):
/** 
 * Notifies this SelectionList about changes to its underlying list store. <p>This changes the flag list. Changes to the source list may cause simultaneous changes to the corresponding selection list.
 */
public void listChanged(ListEvent listChanges){
  int minSelectionIndexBefore=selectionModel.getMinSelectionIndex();
  int maxSelectionIndexBefore=selectionModel.getMaxSelectionIndex();
  updates.beginEvent();
  if (listChanges.isReordering()) {
    int[] sourceReorderMap=listChanges.getReorderMap();
    int[] selectReorderMap=new int[flagList.getCompressedList().size()];
    SparseList previousFlagList=flagList;
    flagList=new SparseList();
    for (int c=0; c < sourceReorderMap.length; c++) {
      Object flag=previousFlagList.get(sourceReorderMap[c]);
      boolean wasSelected=(flag != null);
      flagList.add(c,flag);
      if (wasSelected) {
        int previousIndex=previousFlagList.getCompressedIndex(sourceReorderMap[c]);
        int currentIndex=flagList.getCompressedIndex(c);
        selectReorderMap[currentIndex]=previousIndex;
      }
    }
    updates.reorder(selectReorderMap);
  }
 else {
    while (listChanges.next()) {
      int index=listChanges.getIndex();
      int changeType=listChanges.getType();
      boolean previouslySelected=(flagList.size() > index) && (flagList.get(index) != null);
      int previousSelectionIndex=-1;
      if (previouslySelected)       previousSelectionIndex=flagList.getCompressedIndex(index);
      if (changeType == ListEvent.DELETE) {
        flagList.remove(index);
        if (previouslySelected) {
          updates.addDelete(previousSelectionIndex);
        }
      }
 else       if (changeType == ListEvent.INSERT) {
        if (previouslySelected) {
          if (selectionModel.selectionMode == selectionModel.SINGLE_INTERVAL_SELECTION || selectionModel.selectionMode == selectionModel.MULTIPLE_INTERVAL_SELECTION) {
            flagList.add(index,Boolean.TRUE);
            updates.addInsert(previousSelectionIndex);
          }
 else {
            flagList.add(index,null);
          }
        }
 else {
          flagList.add(index,null);
        }
      }
 else       if (changeType == ListEvent.UPDATE) {
        if (previouslySelected) {
          updates.addUpdate(previousSelectionIndex);
        }
      }
    }
  }
  updates.commitEvent();
  if (minSelectionIndexBefore != 0 && maxSelectionIndexBefore != 0) {
    int minSelectionIndexAfter=selectionModel.getMinSelectionIndex();
    int maxSelectionIndexAfter=selectionModel.getMaxSelectionIndex();
    int changeStart=minSelectionIndexBefore;
    int changeFinish=maxSelectionIndexBefore;
    if (minSelectionIndexAfter != -1 && minSelectionIndexAfter < changeStart)     changeStart=minSelectionIndexAfter;
    if (maxSelectionIndexAfter != -1 && maxSelectionIndexAfter > changeFinish)     changeFinish=maxSelectionIndexAfter;
    selectionModel.fireSelectionChanged(changeStart,changeFinish);
  }
}