RFR: 8089398: [ChoiceBox, ComboBox] throws NPE on setting value on null selectionModel

Jeanette Winzenburg fastegal at openjdk.java.net
Thu Jul 1 14:48:07 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. 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.

-------------

PR: https://git.openjdk.java.net/jfx/pull/557


More information about the openjfx-dev mailing list