-
Notifications
You must be signed in to change notification settings - Fork 463
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
8243115: Spurious invalidations due to bug in IntegerBinding and other classes #198
Conversation
This fixes a bug where the first call to unbind would clear the internal invalidation listener used, resulting in subsequent unbind calls to be no-ops, unless bind was called again first.
👋 Welcome back jhendrikx! A progress list of the required criteria for merging this PR into |
Webrevs
|
/reviewers 2 |
@kevinrushforth |
The title of this PR should match exactly the title of the JBS bug. So:
|
@arapte can you also review this? |
I will review this too anyway. |
Thank you. That will be helpful. |
As I started my review I noticed that |
The fix looks correct and the tests pass. I just wonder why the change to reflection-based construction with |
The Parameterized test constructs some standard Binding objects to run multiple tests with. This works fine if those objects are immutable (or aren't modified during the tests). My new test however does modify them, and other tests would fail with such modified objects (as |
I'm fine with doing a fix, but I need to know which one. Avoiding NPE's and silently doing nothing is IMHO not very desirable as this will give the user of the API no feedback that something went wrong. So I would prefer to fix this by documenting that these cases will result in a NPE. The |
I think that checking the array elements doesn't help much because by the time you can check them they will already be used, and that will throw an NPE implicitly.
|
@kevinrushforth I was going through my open JDK tickets, and saw that this slipped through the cracks. This ticket would need another reviewer still, @arapte could you take a look? |
Looks good to me. Tested on Windows10 and verified that not setting Under a different bug, should we implement the |
(I must have missed this comment) @nlisker What I meant here was to document this behavior, not to add a null check. So for bind: /**
* Start observing the dependencies for changes. If the value of one of the
* dependencies changes, the binding is marked as invalid.
*
* @param dependencies
* the dependencies to observe
+ * @throws NullPointerException when dependencies is null, or any of its elements was null
*/
protected final void bind(Observable... dependencies) {
- if ((dependencies != null) && (dependencies.length > 0)) {
+ if (dependencies.length > 0) {
if (observer == null) {
observer = new BindingHelperObserver(this);
}
for (final Observable dep : dependencies) {
dep.addListener(observer);
}
}
} And if you want to be even more specific, we could add that when a NPE is thrown, the result is undefined (as some dependencies may have been added already). I don't think we want to specify that case.
I don't think we should throw a specific exception (or add a message), only documentation. IMHO, passing |
Thanks, I've merged in master.
Perhaps, currently only more specific implementations (provided mainly by I think it was left up to the subclass to decide whether this would be worth it in order to keep bindings as light weight as possible. |
I would not recommend to make this change as it may break any existing app, even though the app is at wrong to pass |
No, definitely not part of this fix, I was just replying to Nir. |
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.
LGTM
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.
The patch looks good, and I can confirm that it fixes the bug.
@hjohn 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 5 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 (@arapte, @mstr2) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
/integrate |
/sponsor |
Going to push as commit bca1bfc.
Your commit was automatically rebased without conflicts. |
@mstr2 The command |
This fixes a bug where the first call to unbind would clear the internal invalidation listener used, resulting in subsequent unbind calls to be no-ops, unless bind was called again first.
I had to rewrite the parameterized test slightly as Parameterized will only call the parameters method once, and my new test modifies the internal state of the bindings used as parameters (by doing some unbind calls) which was making other tests fail.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx pull/198/head:pull/198
$ git checkout pull/198
Update a local copy of the PR:
$ git checkout pull/198
$ git pull https://git.openjdk.org/jfx pull/198/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 198
View PR using the GUI difftool:
$ git pr show -t 198
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/198.diff