Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8256283: IndexOutOfBoundsException when sorting a TreeTableView #384

wants to merge 2 commits into from


Copy link

@arapte arapte commented Jan 22, 2021

This particular issue JDK-8256283, is a specific case of IOOBE when, rootItem is not shown, some children including first child are selected, then all children are removed and sort() is invoked. The sort() fails with an IOOBE.
This PR only addresses this specific IOOBE.
Root cause of this issue is that the selection is not cleared after rootItems children are removed. In addition to this, there are few other scenarios when selection is not updated correctly, which are collected under an umbrella task JDK-8248217. Fix for JDK-8248217 would require good amount refactoring of selection model.

The fix for this issue is to avoid sort() when rootItem.getChildren().isEmpty().
Added a unit test with the fix, which fails without fix and passes with fix.


  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed


  • JDK-8256283: IndexOutOfBoundsException when sorting a TreeTableView



$ git fetch pull/384/head:pull/384
$ git checkout pull/384

Copy link

@bridgekeeper bridgekeeper bot commented Jan 22, 2021

👋 Welcome back arapte! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr label Jan 22, 2021
Copy link

@mlbridge mlbridge bot commented Jan 22, 2021


Copy link

@kevinrushforth kevinrushforth left a comment

Comments inline.

@@ -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;
Copy link

@kevinrushforth kevinrushforth Jan 22, 2021

That should be || (boolean OR). In addition to being less clear, this will get an NPE if rootItem is ever null, since the bit-wise | operator doesn't short-curcuit the rest of the if test if the first term is true.

Given that this would have caused a regression, and that we don't have a test that would catch it, can you add a test that sets the root to null and calls sort? It will fail with this version of the fix, but would pass without the fix and should pass once you update your fix.

Copy link
Member Author

@arapte arapte Jan 28, 2021

Sorry about that, It was a typo. But it did reveal the missing test.
Corrected the operator to || and added a test as you suggested which fails only with the commit 1 of this PR.

@kevinrushforth kevinrushforth self-requested a review Jan 29, 2021
Copy link

@openjdk openjdk bot commented Jan 29, 2021

@arapte This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file for details.

After integration, the commit message for the final commit will be:

8256283: IndexOutOfBoundsException when sorting a TreeTableView

Reviewed-by: kcr

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 1 new commit pushed to the master branch:

  • 6c1a0ca: 8228363: with side=TOP does not work the first time in the presence of CSS

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready label Jan 29, 2021
Copy link
Member Author

@arapte arapte commented Jan 29, 2021


@openjdk openjdk bot closed this Jan 29, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Jan 29, 2021
Copy link

@openjdk openjdk bot commented Jan 29, 2021

@arapte Since your change was applied there have been 2 commits pushed to the master branch:

  • b0a404d: 8259635: Update to 610.2 version of WebKit
  • 6c1a0ca: 8228363: with side=TOP does not work the first time in the presence of CSS

Your commit was automatically rebased without conflicts.

Pushed as commit db6941d.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants