Skip to content
Permalink
Browse files
8256283: IndexOutOfBoundsException when sorting a TreeTableView
Reviewed-by: kcr
  • Loading branch information
arapte committed Jan 29, 2021
1 parent b0a404d commit db6941dec09d9e1ff14ba23ce25fb6be04545ef9
@@ -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;
@@ -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);

1 comment on commit db6941d

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on db6941d Jan 29, 2021

Please sign in to comment.