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

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

modules/javafx.controls/src/test/java/test/javafx/scene/control/ChoiceBoxTest.java line 162:

> 160:         ByteArrayOutputStream out = new ByteArrayOutputStream();
> 161:         System.setErr(new PrintStream(out, true));
> 162: 

hmm .. this looks a bit unusual. I suspect you want to somehow get around not receiving errors when property changes are involved - if so, the way we typically handle it is to install an uncaughtExceptionHandler to make them appear in the tests (see f.i. ListCellTest). Might have a reason I don't see, though - if so, which?

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

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


More information about the openjfx-dev mailing list