[jfx19] RFR: 8290331 Binding value left null when immediately revalidated in invalidation listener
Michael Strauß
mstrauss at openjdk.org
Fri Jul 15 01:11:51 UTC 2022
On Thu, 14 Jul 2022 23:37:31 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:
> I introduced a bug with the fluent bindings PR which affects all ObjectBindings.
>
> This is the code that fails:
>
> SimpleObjectProperty<Boolean> condition = new SimpleObjectProperty<>(true);
> ObservableValue<String> binding = condition.map(Object::toString);
>
> binding.addListener(o -> { binding.getValue(); });
>
> condition.set(false);
>
> assertEquals(false, binding.getValue()); // returns null (!)
>
> This PR fixes this problem and adds a test case to cover it.
modules/javafx.base/src/main/java/javafx/beans/binding/ObjectBinding.java line 184:
> 182: ExpressionHelper.fireValueChangedEvent(helper);
> 183:
> 184: if (!valid) { // if still invalid after calling listeners...
On a personal note: I think implementation comments are best presented as a block, and not describing individual lines of code. That makes it a bit easier for future authors to work with the code. But that's just my two cents 😊
-------------
PR: https://git.openjdk.org/jfx/pull/829
More information about the openjfx-dev
mailing list