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

ArrayIndexOutOfBoundsException when listening to selection changes on TreeTableView

    Details

      Description

      The related JDK-8152396 is marked as resolved - but isn't for all cases, actually fixed for 2 children ...

      To reproduce, take the example and increase the number of children:

              childNode1.getChildren().addAll(
                  new TreeItem<String>("Node 1-1"),
                  new TreeItem<String>("Node 1-2"),
      // new TreeItem<String>("Node 1-3"),
      // new TreeItem<String>("Node 1-4"),
      // new TreeItem<String>("Node 1-5"),
                  new TreeItem<String>("Node 1-last")
              );

      then expand/collapse until the exception with the same (modulo changes to the implementation managing the selectedItems, the current copied at the end) stacktrace as in the related issue is thrown - the number of exand/collapse cycles depends on the number of children:

      for 3 children: happens in 5th expand
      for 4 children: happens in 3th expand
      (for >=5 children: happens in 1st collapse, but stacktrace different)

      The underlying error is (still!) the incorrect change notification on remove (aka: collapse)

      Listening to selectedItems with 4 children on expanding the selected parrent node, here the notification is correct, 4 items added to the list of selectedItems

      List: { [TreeItem [ value: Node 1-1 ], TreeItem [ value: Node 1-2 ], TreeItem [ value: Node 1-3 ], TreeItem [ value: Node 1-last ]] added at 1 }
      cursor = 0
      Kind of change: added
      Affected range: [1, 5]
      Added size: 4
      Added sublist: [TreeItem [ value: Node 1-1 ], TreeItem [ value: Node 1-2 ], TreeItem [ value: Node 1-3 ], TreeItem [ value: Node 1-last ]]

      Listening to selectedItems with 4 children on collapsing the selected parent node, here the notification is incorrect, only the first two children included in the removed list

       { [TreeItem [ value: Node 1-1 ], TreeItem [ value: Node 1-2 ]] removed at 1 }
      cursor = 0
      Kind of change: removed
      Affected range: [1, 1]
      Removed size: 2
      Removed: [TreeItem [ value: Node 1-1 ], TreeItem [ value: Node 1-2 ]]

      The other way round: will pass (accidentally) for <= two children ..
       
      Consequently, the filteredList gets out off sync.

      The stacktrace:

      Exception in thread "JavaFX Application Thread" java.lang.ArrayIndexOutOfBoundsException
              at java.base/java.lang.System.arraycopy(Native Method)
              at javafx.base/javafx.collections.transformation.FilteredList.addRemove(FilteredList.java:274)
              at javafx.base/javafx.collections.transformation.FilteredList.sourceChanged(FilteredList.java:144)
              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:233)
              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:205)
              at javafx.controls/com.sun.javafx.scene.control.SelectedItemsReadOnlyObservableList.lambda$new$1(SelectedItemsReadOnlyObservableList.java:103)
              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:233)
              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:205)
              at javafx.controls/com.sun.javafx.scene.control.ReadOnlyUnbackedObservableList._endChange(ReadOnlyUnbackedObservableList.java:63)
              at javafx.controls/javafx.scene.control.MultipleSelectionModelBase$SelectedIndicesList._endChange(MultipleSelectionModelBase.java:895)
              at javafx.controls/javafx.scene.control.ControlUtils.updateSelectedIndices(ControlUtils.java:202)
              at javafx.controls/javafx.scene.control.TreeTableView$TreeTableViewArrayListSelectionModel.fireCustomSelectedCellsListChangeEvent(TreeTableView.java:3352)
              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:233)
              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:205)
              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:233)
              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:205)
              at javafx.base/javafx.collections.ModifiableObservableListBase.addAll(ModifiableObservableListBase.java:102)
              at javafx.controls/com.sun.javafx.scene.control.SelectedCellsMap.addAll(SelectedCellsMap.java:146)
              at javafx.controls/javafx.scene.control.TreeTableView$TreeTableViewArrayListSelectionModel.selectIndices(TreeTableView.java:2951)
              at javafx.controls/javafx.scene.control.MultipleSelectionModel.selectRange(MultipleSelectionModel.java:180)
              at de.swingempire.fx.scene.control.selection.TreeTableSelection_original_8152396.selectChildrenOfRows(TreeTableSelection_original_8152396.java:100)





        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                aghaisas Ajit Ghaisas
                Reporter:
                fastegal Jeanette Winzenburg
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: