Program: 32728
Project: 32728
Buggy source:
/** 
 * 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){
  ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().lock();
  try {
    int minSelectionIndexBefore=getMinSelectionIndex();
    int maxSelectionIndexBefore=getMaxSelectionIndex();
    updates.beginEvent();
    if (listChanges.isReordering()) {
      int[] sourceReorderMap=listChanges.getReorderMap();
      int[] selectReorderMap=new int[flagList.blackSize()];
      Barcode previousFlagList=flagList;
      flagList=new Barcode();
      for (int c=0; c < sourceReorderMap.length; c++) {
        Object flag=previousFlagList.get(sourceReorderMap[c]);
        boolean wasSelected=(flag != Barcode.WHITE);
        flagList.add(c,flag,1);
        if (wasSelected) {
          int previousIndex=previousFlagList.getBlackIndex(sourceReorderMap[c]);
          int currentIndex=flagList.getBlackIndex(c);
          selectReorderMap[currentIndex]=previousIndex;
        }
      }
      anchorSelectionIndex=-1;
      leadSelectionIndex=-1;
      updates.reorder(selectReorderMap);
    }
 else {
      while (listChanges.next()) {
        int index=listChanges.getIndex();
        int changeType=listChanges.getType();
        int previousSelectionIndex=flagList.getBlackIndex(index);
        boolean previouslySelected=previousSelectionIndex != -1;
        if (changeType == ListEvent.DELETE) {
          flagList.remove(index,1);
          if (previouslySelected) {
            updates.addDelete(previousSelectionIndex);
          }
        }
 else         if (changeType == ListEvent.INSERT) {
          if (previouslySelected) {
            if (selectionMode == SINGLE_INTERVAL_SELECTION || selectionMode == MULTIPLE_INTERVAL_SELECTION) {
              flagList.addBlack(index,1);
              updates.addInsert(previousSelectionIndex);
            }
 else {
              flagList.addWhite(index,1);
            }
          }
 else {
            flagList.addWhite(index,1);
          }
        }
 else         if (changeType == ListEvent.UPDATE) {
          if (previouslySelected) {
            updates.addUpdate(previousSelectionIndex);
          }
        }
        anchorSelectionIndex=adjustIndex(anchorSelectionIndex,changeType,index);
        leadSelectionIndex=adjustIndex(leadSelectionIndex,changeType,index);
      }
    }
    updates.commitEvent();
    if (minSelectionIndexBefore != 0 && maxSelectionIndexBefore != 0) {
      int minSelectionIndexAfter=getMinSelectionIndex();
      int maxSelectionIndexAfter=getMaxSelectionIndex();
      int changeStart=minSelectionIndexBefore;
      int changeFinish=maxSelectionIndexBefore;
      if (minSelectionIndexAfter != -1 && minSelectionIndexAfter < changeStart)       changeStart=minSelectionIndexAfter;
      if (maxSelectionIndexAfter != -1 && maxSelectionIndexAfter > changeFinish)       changeFinish=maxSelectionIndexAfter;
      valueIsAdjusting=false;
      fireSelectionChanged(changeStart,changeFinish);
    }
  }
  finally {
    ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().unlock();
  }
}

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){
  ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().lock();
  try {
    int minSelectionIndexBefore=getMinSelectionIndex();
    int maxSelectionIndexBefore=getMaxSelectionIndex();
    updates.beginEvent();
    if (listChanges.isReordering()) {
      int[] sourceReorderMap=listChanges.getReorderMap();
      int[] selectReorderMap=new int[flagList.blackSize()];
      Barcode previousFlagList=flagList;
      flagList=new Barcode();
      for (int c=0; c < sourceReorderMap.length; c++) {
        Object flag=previousFlagList.get(sourceReorderMap[c]);
        boolean wasSelected=(flag != Barcode.WHITE);
        flagList.add(c,flag,1);
        if (wasSelected) {
          int previousIndex=previousFlagList.getBlackIndex(sourceReorderMap[c]);
          int currentIndex=flagList.getBlackIndex(c);
          selectReorderMap[currentIndex]=previousIndex;
        }
      }
      anchorSelectionIndex=-1;
      leadSelectionIndex=-1;
      updates.reorder(selectReorderMap);
    }
 else {
      while (listChanges.next()) {
        int index=listChanges.getIndex();
        int changeType=listChanges.getType();
        int previousSelectionIndex=flagList.getBlackIndex(index);
        boolean previouslySelected=previousSelectionIndex != -1;
        if (changeType == ListEvent.DELETE) {
          flagList.remove(index,1);
          if (previouslySelected) {
            updates.addDelete(previousSelectionIndex);
          }
        }
 else         if (changeType == ListEvent.INSERT) {
          if (previouslySelected) {
            if (selectionMode == SINGLE_INTERVAL_SELECTION || selectionMode == MULTIPLE_INTERVAL_SELECTION) {
              flagList.addBlack(index,1);
              updates.addInsert(previousSelectionIndex);
            }
 else {
              flagList.addWhite(index,1);
            }
          }
 else {
            flagList.addWhite(index,1);
          }
        }
 else         if (changeType == ListEvent.UPDATE) {
          if (previouslySelected) {
            updates.addUpdate(previousSelectionIndex);
          }
        }
        anchorSelectionIndex=adjustIndex(anchorSelectionIndex,changeType,index);
        leadSelectionIndex=adjustIndex(leadSelectionIndex,changeType,index);
      }
    }
    updates.commitEvent();
    if (minSelectionIndexBefore != -1 && maxSelectionIndexBefore != -1) {
      int minSelectionIndexAfter=getMinSelectionIndex();
      int maxSelectionIndexAfter=getMaxSelectionIndex();
      int changeStart=minSelectionIndexBefore;
      int changeFinish=maxSelectionIndexBefore;
      if (minSelectionIndexAfter != -1 && minSelectionIndexAfter < changeStart)       changeStart=minSelectionIndexAfter;
      if (maxSelectionIndexAfter != -1 && maxSelectionIndexAfter > changeFinish)       changeFinish=maxSelectionIndexAfter;
      valueIsAdjusting=false;
      fireSelectionChanged(changeStart,changeFinish);
    }
  }
  finally {
    ((InternalReadWriteLock)eventList.getReadWriteLock()).internalLock().unlock();
  }
}