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

Jeanette Winzenburg fastegal at openjdk.java.net
Wed Jul 7 10:29:52 UTC 2021


On Tue, 6 Jul 2021 20:20:23 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)
>
> Marius Hanl has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Added another cbx test + cleaned up exception handler + let the exception bubble up instead of try-catch

good :) Verified that the two test methods in combo test indeed expose the two throwing locations before the fix.

There is one minor change I would recommend, see inline

modules/javafx.controls/src/test/java/test/javafx/scene/control/ComboBoxTest.java line 319:

> 317: 
> 318:         ComboBox<String> comboBox = new ComboBox<>();
> 319:         comboBox.setButtonCell(buttonCell);

KISS - the buttonCell or not has no effect if there is no skin :)

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

Changes requested by fastegal (Reviewer).

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


More information about the openjfx-dev mailing list