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

MultipleSelectionModel throws IndexOutOfBoundException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • jfx20
    • jfx15
    • javafx
    • None
    • b10

      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);
      }
      ```

            fkirmaier Florian Kirmaier
            fkirmaier Florian Kirmaier
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: