NullPointerException thrown when native query returns 1 row, 1 column and the value is null #769
Labels
status: pr submitted
A pull request has been submitted for the issue
type: bug
Something isn't working
Description
In one of our repository classes, the query expects a
String
as result type, but it might occasionally returnnull
value.When this happens a NullPointerException is thrown instead of the expected empty Optional.
Steps to Reproduce
with this repository:
When calling
somethingThatMightSometimesReturnNull()
a null pointer exception is thrown here:https://github.com/micronaut-projects/micronaut-data/blob/master/data-runtime/src/main/java/io/micronaut/data/runtime/mapper/ResultReader.java#L50
Since the value is
null
, calling the.getClass()
method will thrown a NullPointerExceptionExpected Behaviour
When a null value is the result of a query, an empty Optional should be returned.
Actual Behaviour
When a null value is the result of a query, a NullPointerException is thrown.
Environment Information
The text was updated successfully, but these errors were encountered: