Sorted Editable Grid with new data (bean) throws NPE

I have a grid which is editable and should be sorted. Without sorting everything works fine. But when I add grid.sort(firstColumn); it bails out with a NPE when I add a new bean where the fields have null values.

[code]
Caused by: java.lang.NullPointerException: value cannot be null
at java.util.Objects.requireNonNull(Objects.java:228)[:1.8.0_111]

at com.vaadin.ui.AbstractTextField.setValue(AbstractTextField.java:96)
at com.vaadin.ui.AbstractTextField.setValue(AbstractTextField.java:46)
at com.vaadin.data.Binder$BindingImpl.initFieldValue(Binder.java:890)
at com.vaadin.data.Binder$BindingImpl.access$100(Binder.java:763)
at com.vaadin.data.Binder.lambda$readBean$11(Binder.java:1380)[218:com.vaadin.server:8.0.0]

at java.lang.Iterable.forEach(Iterable.java:75)[:1.8.0_111]

at com.vaadin.data.Binder.readBean(Binder.java:1380)[218:com.vaadin.server:8.0.0]

at com.vaadin.ui.components.grid.EditorImpl.doEdit(EditorImpl.java:224)
at com.vaadin.ui.components.grid.EditorImpl$1.bind(EditorImpl.java:150)
... 39 more

[/code]Can I set somewhere my own comparator which handles null values? Or is there any other workaround?

Thanks in advance.

Mihael

Yes, that is possible when you use ListDataProvider instance in Grid, it has a method addSortComparator()

https://vaadin.com/api/8.0.1/com/vaadin/data/provider/ListDataProvider.html#addSortComparator-com.vaadin.server.SerializableComparator-

Here is the interface you should extend

https://vaadin.com/api/8.0.1/com/vaadin/server/SerializableComparator.html

Thanks. That did the job.