-
Notifications
You must be signed in to change notification settings - Fork 542
8301763: Adding children to wrong index leaves inconsistent state in Parent#childrenSet #1136
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
Conversation
|
👋 Welcome back lkostyra! A progress list of the required criteria for merging this PR into |
Webrevs
|
|
I think it may be better to do this check in the callers of Also, for the cases where Furthermore, it should be an I noticed there are similar problems in This will attach a listener to the element (assuming it is an |
|
Thanks for your notes, I was wondering if there was a better approach. I'll rework the patch. |
|
As a small note, the issue is solved with current patches, however I think the best solution would be what I mentioned in the original PR message - an interface in |
hjohn
left a comment
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.
I think ObservableListWrapper#remove(int, int) also needs a check index check, or it may end up remove some items and then throw an exception (exceptions thrown from collections should not modify its state).
| Objects.requireNonNull(col); | ||
| onProposedChange(Collections.unmodifiableList(new ArrayList<>(col)), 0, size()); |
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.
It's good to make it explicit. It already threw NPE because of new ArrayList<>(col), so this is not a change.
|
|
||
| @Override | ||
| public boolean removeAll(Collection<?> c) { | ||
| Objects.requireNonNull(c); |
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.
Looks like a good change, if c was null and the backing list was empty, this would not throw NPE, but now it does.
| // below call should throw no exception - if it does, internal state is corrupted | ||
| g.getChildren().remove(0); | ||
| } | ||
|
|
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.
I think you should also add tests for the null cases, if they aren't part of this test already.
I'm not convinced this is needed or desirable. The A roll back mechanism would just complicate the code for very little benefit (a correct FX application won't run into these situations, you'll only be likely to encounter them during development). The whole mechanism surrounding the children list and bad additions should be seen as a best effort early warning system (like ConcurrentModificationExeption). With this fix I don't see any other ways you could get it in a bad state. |
Understood, let's stick with current approach then. |
kevinrushforth
left a comment
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.
Looks good.
|
@lukostyra 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 10 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@hjohn, @kevinrushforth) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
|
/integrate |
|
@lukostyra |
|
/sponsor |
|
Going to push as commit 4b24c86.
Your commit was automatically rebased without conflicts. |
|
@hjohn @lukostyra Pushed as commit 4b24c86. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This issue happened because
childSetmember of Parent was modified duringonProposedChange()call - that call did not recognize negative indexes as invalid, which caused an exception when actually adding the Node to a List.This seemed like the simplest solution which doesn't rework a lot of code underneath. Exceptions coming from a backing list/collection technically are handled by
VetoableListDecorator's try-catch clauses, howeverVetoableListDecoratordoes not provide an interface to react when such an exception happens - without it we cannot revertchildSetback to its original state.Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1136/head:pull/1136$ git checkout pull/1136Update a local copy of the PR:
$ git checkout pull/1136$ git pull https://git.openjdk.org/jfx.git pull/1136/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1136View PR using the GUI difftool:
$ git pr show -t 1136Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1136.diff
Webrev
Link to Webrev Comment