Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8256283: IndexOutOfBoundsException when sorting a TreeTableView
Reviewed-by: kcr
  • Loading branch information
arapte committed Jan 29, 2021
1 parent b0a404d commit db6941d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Expand Up @@ -579,7 +579,7 @@ public static int getNodeLevel(TreeItem<?> node) {
@Override public Boolean call(TreeTableView table) {
try {
TreeItem rootItem = table.getRoot();
if (rootItem == null) return false;
if (rootItem == null || rootItem.getChildren().isEmpty()) return false;

TreeSortMode sortMode = table.getSortMode();
if (sortMode == null) return false;
Expand Down
Expand Up @@ -753,6 +753,32 @@ private void verifySelectionAfterPermutation() {
treeTableView.sort();
}

@Test public void testNoIOOBEWhenSortingAfterSelectAndClearRootChildren() {
TreeTableView<String> ttv = new TreeTableView<>();
TreeItem<String> root = new TreeItem<>("root");
TreeItem<String> child = new TreeItem<>("child");
root.getChildren().add(child);
root.setExpanded(true);
ttv.setRoot(root);
ttv.setShowRoot(false);

TreeTableColumn<String, String> ttc = new TreeTableColumn<>("Column");
ttv.getSortOrder().add(ttc);

ttv.getSelectionModel().select(0);
root.getChildren().remove(0);
ControlTestUtils.runWithExceptionHandler(() -> {
ttv.sort();
});
}

@Test public void testNPEWhenRootItemIsNull() {
TreeTableView<String> ttv = new TreeTableView<>();
ControlTestUtils.runWithExceptionHandler(() -> {
ttv.sort();
});
}

@Test public void testChangingSortPolicyUpdatesItemsList() {
TreeTableColumn<String, String> col = initSortTestStructure();
col.setSortType(DESCENDING);
Expand Down

1 comment on commit db6941d

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.