clarify behavior when null is passed to Converter::convert
See original GitHub issuePer a discussion in #495, null
should never be passed to a converter. We should clarify what exception should be thrown if this occurs.
Obvious choices are NullPointerException
or IllegalArgumentException
.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
org.springframework.core.convert.converter.Converter<S, T ...
So it explicitly says that you can never pass null into the convert function. Conversely, what the convert function returns can be null:....
Read more >Converter (Guava: Google Core Libraries for Java 20.0 API)
The convert(A) method handles this null behavior for all converters; implementations of doForward(A) and doBackward(B) are guaranteed to never be passed ...
Read more >XAML: Nested Converters / Tinkoff.ru Blog ...
We allow it to be IValueConverter - this will give us the opportunity to use existing converters as a nested one. The conversion...
Read more >NumPy User Guide - Numpy and Scipy Documentation
Negative integers behave the same as regular Python negative indexes. ... In the following example, the converter convert.
Read more >AppendWhere
ReferenceEquals((object) op, (object) null)) return src; ParameterExpression thisExpression ... Lambda(converter.Convert(thisExpression, op) ...
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
We settled on NPE if the value null is passed to convert().
The convention used throughout the JDK is
NullPointerException
. Given that this is technically an SPI I think that is sufficient, and also allows use of the standardObjects.requireNonNull
methods.