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

IOOBE with ListChangeListener added to the selectedItems list of a TableView

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8u301, openjfx11.0.2, openjfx17
    • Fix Version/s: openjfx19
    • Component/s: javafx
    • Labels:
      None

      Description

      Given a TableView with multiple selection mode and cell selection enabled, with a ListChangeListener added to the selectedItems list of the TableView's selection model. If the first cell of a row is selected, when command+clicking another cell in the same row, this exception is thrown:

      Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException: toIndex = 2
              at java.base/java.util.AbstractList.subListRangeCheck(AbstractList.java:507)
              at java.base/java.util.AbstractList.subList(AbstractList.java:497)
              at javafx.base/com.sun.javafx.collections.ChangeHelper.addRemoveChangeToString(ChangeHelper.java:38)
              at javafx.base/javafx.collections.ListChangeBuilder$SingleChange.toString(ListChangeBuilder.java:630)
              at java.base/java.lang.String.valueOf(String.java:2951)
              at com.gluonhq.TableSelectionIssue.lambda$start$0(TableSelectionIssue.java:52)
              at javafx.base/com.sun.javafx.collections.ListListenerHelper$SingleChange.fireValueChangedEvent(ListListenerHelper.java:164)
              at javafx.base/com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
              at javafx.base/javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:239)
              at javafx.base/javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
              at javafx.base/javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
              at javafx.base/javafx.collections.ObservableListBase.endChange(ObservableListBase.java:211)
              at javafx.controls/com.sun.javafx.scene.control.SelectedItemsReadOnlyObservableList.lambda$new$0(SelectedItemsReadOnlyObservableList.java:91)
              at javafx.base/com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:329)
              at javafx.base/com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
              at javafx.base/javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:239)
              at javafx.base/javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
              at javafx.base/javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
              at javafx.base/javafx.collections.ObservableListBase.endChange(ObservableListBase.java:211)
              at javafx.controls/com.sun.javafx.scene.control.ReadOnlyUnbackedObservableList._endChange(ReadOnlyUnbackedObservableList.java:64)
              at javafx.controls/javafx.scene.control.MultipleSelectionModelBase$SelectedIndicesList._endChange(MultipleSelectionModelBase.java:898)
              at javafx.controls/javafx.scene.control.ControlUtils.updateSelectedIndices(ControlUtils.java:204)
              at javafx.controls/javafx.scene.control.TableView$TableViewArrayListSelectionModel.fireCustomSelectedCellsListChangeEvent(TableView.java:3026)
              at javafx.base/com.sun.javafx.collections.ListListenerHelper$SingleChange.fireValueChangedEvent(ListListenerHelper.java:164)
              at javafx.base/com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
              at javafx.base/javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:239)
              at javafx.base/javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
              at javafx.base/javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
              at javafx.base/javafx.collections.ObservableListBase.endChange(ObservableListBase.java:211)
              at javafx.base/javafx.collections.transformation.SortedList.sourceChanged(SortedList.java:111)
              at javafx.base/javafx.collections.transformation.TransformationList.lambda$getListener$0(TransformationList.java:106)
              at javafx.base/javafx.collections.WeakListChangeListener.onChanged(WeakListChangeListener.java:88)
              at javafx.base/com.sun.javafx.collections.ListListenerHelper$SingleChange.fireValueChangedEvent(ListListenerHelper.java:164)
              at javafx.base/com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
              at javafx.base/javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:239)
              at javafx.base/javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
              at javafx.base/javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
              at javafx.base/javafx.collections.ObservableListBase.endChange(ObservableListBase.java:211)
              at javafx.base/javafx.collections.ModifiableObservableListBase.add(ModifiableObservableListBase.java:162)
              at java.base/java.util.AbstractList.add(AbstractList.java:111)
              at javafx.controls/com.sun.javafx.scene.control.SelectedCellsMap.add(SelectedCellsMap.java:105)
              at javafx.controls/javafx.scene.control.TableView$TableViewArrayListSelectionModel.select(TableView.java:2508)
              at javafx.controls/javafx.scene.control.TableView$TableViewSelectionModel.select(TableView.java:1952)
              at javafx.controls/com.sun.javafx.scene.control.behavior.TableCellBehaviorBase.doSelect(TableCellBehaviorBase.java:155)
              at javafx.controls/com.sun.javafx.scene.control.behavior.CellBehaviorBase.mousePressed(CellBehaviorBase.java:176)
              at javafx.controls/com.sun.javafx.scene.control.inputmap.InputMap.handle(InputMap.java:274)
              at javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:247)
              at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
              at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
              at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
              at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
              at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
              at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
              at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
              at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
              at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
              at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
              at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
              at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
              at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
              at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
              at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
              at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
              at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
              at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
              at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
              at javafx.graphics/javafx.scene.Scene$MouseHandler.process(Scene.java:3880)
              at javafx.graphics/javafx.scene.Scene.processMouseEvent(Scene.java:1873)
              at javafx.graphics/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2606)
              at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:411)
              at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:301)
              at java.base/java.security.AccessController.doPrivileged(Native Method)
              at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:450)
              at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:423)
              at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:449)
              at javafx.graphics/com.sun.glass.ui.View.handleMouseEvent(View.java:557)
              at javafx.graphics/com.sun.glass.ui.View.notifyMouse(View.java:943)
              at javafx.graphics/com.sun.glass.ui.mac.MacView.notifyMouse(MacView.java:127)

      This can be reproduced with any JavaFX version from 11 to head.

      Attached is a test that can be used to reproduce the issue.

      Steps:

      Steps:
      1. Select the first cell in the first row by mouse clicking on it. Log:
      Change: { [Person{a b}] added at 0 }, selected items: [Person{a b}]

      2. Press Command (Mac) or Control (Windows) and mouse click to select the other cell in the same row. The exception is thrown.
       
      However, if the second cell is selected, command+click the first one works as expected and no exception is thrown.

      It can be seen that with any given selected cell, any other selection of a cell in the same row with higher column index leads to the exception, but when the column index is lower, there is no exception and selection works as expected.

      When the ListChangeListener is removed, there is no exception in any case.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jpereda Jose Pereda
              Reporter:
              jpereda Jose Pereda
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: