Bug Report: NPE when @CacheResult annotated method returns null #7049
Labels
Status: Open
Issue has been triaged by the front-line engineers and is being worked on verification
Type: Bug
Label issue as a bug defect
Brief Summary
My runtime is Payara (Community 5.2022.5 and Enterprise 5.67) with the integrated Hazelcast as JCache layer.
In a CDI bean I have a public method annotated with @CacheResult. Under some circumstances this method can return null. Currently, this results in a NPE quite deep in Hazelcast.
Expected Outcome
I expect that the method returns null and probably doesn't cache anything (because JCache doesn't support to cache null values).
This expectation is supported by the JCache TCK test org.jsr107.tck.annotation.AbstractBlogManagerInterceptionTest#test_AT_CacheRemoveEntry() where in the end it is asserted that the annotated method returns a null value.
Current Outcome
Currently, the following exception is thrown:
which is probably caused by the missing null-check in
CacheResultInterceptor#cacheResult(...)
between proceeding and before putting as the specification ofjavax.cache.Cache#put(K, V)
declares it to throw a NPE when invoked with a null value.Reproducer
Apply following patch to https://github.com/payara/Payara-Examples/blob/main/javaee/jcache/jcache-cdi/src/main/java/fish/payara/examples/jcachecdi/Model.java
Then start the application and invoke the Servlet with
POST /NewServlet?number=0
Operating System
Suse Linux, MacOS
JDK Version
Corretto-11.0.20
Payara Distribution
Payara Server Full Profile
The text was updated successfully, but these errors were encountered: