Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8256397

MultipleSelectionModel throws IndexOutOfBoundException

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: openjfx15
    • Fix Version/s: tbd
    • Component/s: javafx
    • Labels:
      None

      Description

      Sometimes the MultipleSelectionModel throws IndexOutOfBoundException.
      Details can be extracted from the unit-test.
      Fix with PR will follow any moment.

      ```
      @Test
      public void testMultipleSelectionModelSpecialCase() throws InterruptedException {
          ListView<String> listView = new ListView<>();

          listView.getItems().add("item-0");
          listView.getItems().add("item-1");
          listView.getItems().add("item-2");
          listView.getItems().add("item-3");

          MultipleSelectionModel<String> selectionModel = listView.getSelectionModel();
          selectionModel.setSelectionMode(SelectionMode.MULTIPLE);

          selectionModel.getSelectedIndices().addListener((ListChangeListener<? super Integer>) c -> {
              while (c.next()) {
                  try {
                      c.getAddedSubList(); // --> java.lang.IndexOutOfBoundsException: [ fromIndex: 0, toIndex: 5, size: 3 ]
                  } catch (IndexOutOfBoundsException e) {
                      fail(e.getMessage());
                  }
              }
          });
          selectionModel.selectIndices(0, /*1, IMPORTANT: remove some index */ 2, 3);
      }
      ```

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                fkirmaier Florian Kirmaier
                Reporter:
                fkirmaier Florian Kirmaier
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: