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

IndexOutOfBoundsException when sorting TreeTableView with multiple rows selected

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 8u201
    • javafx

      ADDITIONAL SYSTEM INFORMATION :
      MacOS 10.14.4
      Java 1.8.0_201

      A DESCRIPTION OF THE PROBLEM :
      If you select two or more rows in a TreeTableView and then sort on a column, you get:

      Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException
      at com.sun.javafx.scene.control.ReadOnlyUnbackedObservableList.subList(ReadOnlyUnbackedObservableList.java:136)
      at javafx.collections.ListChangeListener$Change.getAddedSubList(ListChangeListener.java:242)
      at javafx.scene.control.TreeTableView$TreeTableViewArrayListSelectionModel.handleSelectedCellsListChangeEvent(TreeTableView.java:3244)
      at javafx.scene.control.TreeTableView$TreeTableViewArrayListSelectionModel.access$2000(TreeTableView.java:2289)
      at javafx.scene.control.TreeTableView.sort(TreeTableView.java:1817)
      at javafx.scene.control.TreeTableView.doSort(TreeTableView.java:1855)
      at javafx.scene.control.TreeTableView.lambda$new$237(TreeTableView.java:383)
      at com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:329)
      at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
      at javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:233)
      at javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
      at javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
      at javafx.collections.ObservableListBase.endChange(ObservableListBase.java:205)
      at javafx.collections.ModifiableObservableListBase.setAll(ModifiableObservableListBase.java:90)
      at javafx.collections.ObservableListBase.setAll(ObservableListBase.java:250)
      at com.sun.javafx.scene.control.skin.TableColumnHeader.sortColumn(TableColumnHeader.java:795)
      at com.sun.javafx.scene.control.skin.TableColumnHeader.lambda$static$136(TableColumnHeader.java:243)
      at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
      at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
      at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
      at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
      at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
      at javafx.event.Event.fireEvent(Event.java:198)
      at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
      at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
      at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
      at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:394)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$353(GlassViewEventHandler.java:432)
      at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:431)
      at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
      at com.sun.glass.ui.View.notifyMouse(View.java:937)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Select 2 rows
      Sort the column
      Crash

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Should not crash
      ACTUAL -
      IndexOutOfBoundsException

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.beans.property.ReadOnlyStringWrapper;
      import javafx.scene.Group;
      import javafx.scene.Scene;
      import javafx.scene.control.TreeTableColumn;
      import javafx.scene.control.TreeTableColumn.CellDataFeatures;
      import javafx.scene.control.SelectionMode;
      import javafx.scene.control.TreeItem;
      import javafx.scene.control.TreeTableView;
      import javafx.stage.Stage;
       
      public class TreeTableViewSample extends Application {
       
          public static void main(String[] args) {
              Application.launch(args);
          }
          
          @Override
          public void start(Stage stage) {
              stage.setTitle("Tree Table View Samples");
              final Scene scene = new Scene(new Group(), 200, 400);
              Group sceneRoot = (Group)scene.getRoot();
            
              //Creating tree items
              final TreeItem<String> childNode1 = new TreeItem<>("Child Node 1");
              final TreeItem<String> childNode2 = new TreeItem<>("Child Node 2");
              final TreeItem<String> childNode3 = new TreeItem<>("Child Node 3");
              
              //Creating the root element
              final TreeItem<String> root = new TreeItem<>("Root node");
              root.setExpanded(true);
           
              //Adding tree items to the root
              root.getChildren().setAll(childNode1, childNode2, childNode3);

              //Creating a column
              TreeTableColumn<String,String> column = new TreeTableColumn<>("Column");
              column.setPrefWidth(150);
           
              //Defining cell content
              column.setCellValueFactory((CellDataFeatures<String, String> p) ->
                  new ReadOnlyStringWrapper(p.getValue().getValue()));

              //Creating a tree table view
              final TreeTableView<String> treeTableView = new TreeTableView<>(root);
              treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

              treeTableView.getColumns().add(column);
              treeTableView.setPrefWidth(152);
              treeTableView.setShowRoot(true);
              sceneRoot.getChildren().add(treeTableView);
              stage.setScene(scene);
              stage.show();
          }
      }
      ---------- END SOURCE ----------

            arapte Ambarish Rapte
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: