Details
-
Bug
-
Status: Closed
-
Blocker
-
Resolution: Fixed
-
None
-
None
Description
While checking the current state of the JCR Bundle resource bundle against an existing codebase, I found that it throws errors like this:
Caused by: java.lang.NullPointerException: null at org.apache.sling.jcr.resource.internal.JcrValueMap.get(JcrValueMap.java:110) [org.apache.sling.jcr.resource:3.2.1.SNAPSHOT]
This is caused by calling ValueMap.get(propertyName, null). This was working with the version 3.2.0 of the jcr resource bundle.
The defaultValue parameter is marked as NonNull, and the javadoc for the ValueMap.get() method states this:
Implementation hint: In the past it was allowed to call this with a 2nd parameter being null. Therefore all implementations should internally call Map.get(Object) when the 2nd parameter has value null.
That means that some backward-incompatible change has been made by declaring this parameter non-null (in the API).
For the implementation that despite this parameter being marked as non-null, all implementations still need to do explicit checks for null and handle them properly.