MultipleSelectionModelBase::clearSelection() is incorrect

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 8u60
    • Affects Version/s: 8u31
    • Component/s: javafx
    • None

      Code snippet from MultipleSelectionModelBase.java, function public void clearSelection() , line 630:

                  List<Integer> removed = new AbstractList<Integer>() {
                      final BitSet clone = (BitSet) selectedIndices.clone();

                      @Override public Integer get(int index) {
                          return clone.nextSetBit(index);
                      }

                      @Override public int size() {
                          return clone.cardinality();
                      }
                  };

      Suppose indices 2 and 3 were selected before the call.
      The removed list as implemented above will look like [2, 2] instead of [2, 3] which should be obvious from the code.

      Why not use createListFromBitSet(...) as in clearAndSelect() ?

            Assignee:
            Jonathan Giles
            Reporter:
            J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: