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

TableView.getSelectionModel().clearSelection() results in IndexOutOfBoundsException

XMLWordPrintable

    • generic
    • generic

      FULL PRODUCT VERSION :
      java version "9.0.1"
      Java(TM) SE Runtime Environment (build 9.0.1+11)
      Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      openSUSE Tumbleweed (lastest patches applied)

      A DESCRIPTION OF THE PROBLEM :
      Attempting to clear the selection on a table with the following code:

      table.getSelectionModel().clearSelection() or any variation thereof will throw the following:

      Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException: [ fromIndex: 0, toIndex: 1, size: 0 ]
      at javafx.controls/com.sun.javafx.scene.control.ReadOnlyUnbackedObservableList.subList(ReadOnlyUnbackedObservableList.java:170)
      at javafx.base/javafx.collections.ListChangeListener$Change.getAddedSubList(ListChangeListener.java:242)
      at javafx.controls/javafx.scene.control.ControlUtils.updateSelectedIndices(ControlUtils.java:168)
      at javafx.controls/javafx.scene.control.TableView$TableViewArrayListSelectionModel.fireCustomSelectedCellsListChangeEvent(TableView.java:3028)
      at javafx.controls/javafx.scene.control.TableView$TableViewArrayListSelectionModel.clearAndSelect(TableView.java:2482)
      at javafx.controls/javafx.scene.control.TableView$TableViewSelectionModel.clearAndSelect(TableView.java:1966)
      at javafx.controls/com.sun.javafx.scene.control.behavior.TableCellBehaviorBase.simpleSelect(TableCellBehaviorBase.java:213)
      at javafx.controls/com.sun.javafx.scene.control.behavior.TableCellBehaviorBase.doSelect(TableCellBehaviorBase.java:146)
      at javafx.controls/com.sun.javafx.scene.control.behavior.CellBehaviorBase.mousePressed(CellBehaviorBase.java:176)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      try to clear the selection on a TableView.getSelectionModel().clearSelection();

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      should clear the selection
      ACTUAL -
      throws the exception

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException: [ fromIndex: 0, toIndex: 1, size: 0 ]
      at javafx.controls/com.sun.javafx.scene.control.ReadOnlyUnbackedObservableList.subList(ReadOnlyUnbackedObservableList.java:170)
      at javafx.base/javafx.collections.ListChangeListener$Change.getAddedSubList(ListChangeListener.java:242)
      at javafx.controls/javafx.scene.control.ControlUtils.updateSelectedIndices(ControlUtils.java:168)
      at javafx.controls/javafx.scene.control.TableView$TableViewArrayListSelectionModel.fireCustomSelectedCellsListChangeEvent(TableView.java:3028)
      at javafx.controls/javafx.scene.control.TableView$TableViewArrayListSelectionModel.clearAndSelect(TableView.java:2482)
      at javafx.controls/javafx.scene.control.TableView$TableViewSelectionModel.clearAndSelect(TableView.java:1966)
      at javafx.controls/com.sun.javafx.scene.control.behavior.TableCellBehaviorBase.simpleSelect(TableCellBehaviorBase.java:213)
      at javafx.controls/com.sun.javafx.scene.control.behavior.TableCellBehaviorBase.doSelect(TableCellBehaviorBase.java:146)
      at javafx.controls/com.sun.javafx.scene.control.behavior.CellBehaviorBase.mousePressed(CellBehaviorBase.java:176)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Any TableView instance:

      TableView.getSelectionModel().clearSelection();
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      don't try to clear the selection

        1. ClearSelectionTest.java
          4 kB
          Priyanka Mangal
        2. DavisSelectionTest.java
          5 kB
          Priyanka Mangal

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: