question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

clarify behavior when null is passed to Converter::convert

See original GitHub issue

Per 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:closed
  • Created 4 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Emily-Jiangcommented, Mar 12, 2020

We settled on NPE if the value null is passed to convert().

1reaction
dmlloydcommented, Mar 12, 2020

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 standard Objects.requireNonNull methods.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found