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
Conversation
👋 Welcome back arapte! A progress list of the required criteria for merging this PR into |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@arapte This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
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
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
/integrate |
@arapte Since your change was applied there have been 2 commits pushed to the
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. |
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.
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jfx pull/384/head:pull/384
$ git checkout pull/384