vaadin / vaadin-time-picker-flow

Vaadin Flow Java API for vaadin/vaadin-time-picker Web Component
https://vaadin.com/components/vaadin-time-picker
Other
6 stars 11 forks source link

Component demo "Time Picker With Step Setting" throws NPE when clearing time value field #94

Closed paulroemer closed 4 years ago

paulroemer commented 4 years ago

Where:

What: Select a time, delete it again and press enter.

vaadin.com(opens in new tab)APP Unhandled NullPointerException on page https://vaadin.com/components/vaadin-time-picker/java-examples

com.vaadin.flow.component.timepicker.demo.TimePickerView.lambda$createTimePickerWithStepSetting$1da64346$1(TimePickerView.java:150)
Haprog commented 4 years ago

The problem is this event listener that doesn't have a null check for the value: https://github.com/vaadin/vaadin-time-picker-flow/blob/2.0.6/vaadin-time-picker-flow-demo/src/main/java/com/vaadin/flow/component/timepicker/demo/TimePickerView.java#L150

        timePicker.addValueChangeListener(event -> {
            LocalTime value = event.getValue();
            localTimeValue.setText(String.format(localTimeValueFormat,
                    value.getHour(), value.getMinute(), value.getSecond(), // <- value is null when set to empty on client
                    value.get(ChronoField.MILLI_OF_SECOND)));
        });

Very easy to fix.

web-padawan commented 4 years ago

Fixed by #102