RFR: 8089398: [ChoiceBox, ComboBox] throws NPE on setting value on null selectionModel
Marius Hanl
mhanl at openjdk.java.net
Thu Jul 1 15:33:03 UTC 2021
On Wed, 30 Jun 2021 15:03:50 GMT, Marius Hanl <mhanl at openjdk.org> wrote:
> This PR fixes 2 NPEs in Choice-and ComboBox, when the selection model is null.
>
> ChoiceBox:
> - Null check in **valueProperty()** listener
>
> ComboBox:
> - Null check in **valueProperty()** listener
> - Null check in **ComboBoxListViewSkin#updateValue()**
>
> The tests checks, that no NPE is printed to the console. They also checks, that the set value is still displayed (either in the ComboBox button cell or the ChoiceBox display label)
> FYI: there's an open discussion (which .. dried up ;) as to how to handle null selectionModel (there are similar issues across different controls) - adding a null check would be the most simple, disallowing null and provide a default do-nothing model would be another option, see f.i. [javafxports/openjdk-jfx#569](https://github.com/javafxports/openjdk-jfx/issues/569).
>
> We should decide about the approach, my preference would be to go for the most simple: simply check against null everywhere.
That would be also my approach.
I don't see any benefit with a noop selection model, but we need/should cleanup some null checks and somehow still silently set a selection model while we as a developer set it to null (so I guess we expected null to be returned when we call the getSelectionModel())
-------------
PR: https://git.openjdk.java.net/jfx/pull/557
More information about the openjfx-dev
mailing list