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

Closed
wants to merge 2 commits into from

Conversation

arapte
Copy link
Member

@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.


Progress

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

Issue

  • JDK-8256283: IndexOutOfBoundsException when sorting a TreeTableView

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jfx pull/384/head:pull/384
$ git checkout pull/384

@bridgekeeper
Copy link

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 Ready for review label Jan 22, 2021
@mlbridge
Copy link

mlbridge bot commented Jan 22, 2021

Webrevs

Copy link
Member

@kevinrushforth kevinrushforth left a 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;
Copy link
Member

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.

Copy link
Member Author

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.

@openjdk
Copy link

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 CONTRIBUTING.md 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: ContextMenu.show 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 Ready to be integrated label Jan 29, 2021
@arapte
Copy link
Member Author

arapte commented Jan 29, 2021

/integrate

@openjdk openjdk bot closed this Jan 29, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Ready to be integrated rfr Ready for review labels Jan 29, 2021
@openjdk
Copy link

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: ContextMenu.show 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.

@arapte arapte deleted the TTV_IOOBE_on_sort branch May 10, 2022 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated
2 participants