StringToIntegerConverter makes TextField throw NullPointerException on null Integer value
See original GitHub issueVaadin 14.0.9. Binding a null
Integer
field to a TextField
via StringToIntegerConverter
fails with NPE. This is the most basic use-case which simply must work out of the box.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
java - Why do I get NullPointerException when my Integer ...
Integer [] numbers = new Integer[input.toString().length()];. Integer is an object type, so all the values in the array start off as null. If...
Read more >CRUD component issue - Vaadin
private static BinderCrudEditor<Product> createForm() { TextField name = new ... NullPointerException: Null value is not supported.
Read more >How to Fix and Avoid NullPointerException in Java - Rollbar
NullPointerException in Java occurs when a variable is accessed which is not pointing to any object and refers to nothing or null.
Read more >9 Things about null keyword and reference in Java
Any wrapper class with value null will throw java.lang.NullPointerException when Java unbox them into primitive values.
Read more >How to Handle NullPointerException in Java - freeCodeCamp
The idea is that, when you expect a value to be null , its better to put a null check on that variable....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://github.com/vaadin/flow/pull/6757 adds a mention of null representations to the exception message.
@Legioth very good point with magic+DI, I avoid DI like a plague.
That sounds really good. Rethrowing as RuntimeException changes exception type which should be avoided. Rethrowing only in special case as described above sounds good to me, and navigates the dev to the correct solution.
Yeah, StringToIntegerConverter already has 4 constructors and with optional boolean param there would be too many. We could add
converter.withNullValue("")
but there’s no point since we can already callbinding.withNullRepresentation("")
. I think rethrow is the best solution.