You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Joerg Hoh (Jira)" <ji...@apache.org> on 2022/09/05 18:36:00 UTC

[jira] [Commented] (SLING-11567) ValueMap.get() with null defaultValue not working

    [ https://issues.apache.org/jira/browse/SLING-11567?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17600508#comment-17600508 ] 

Joerg Hoh commented on SLING-11567:
-----------------------------------

PR for discussion: https://github.com/apache/sling-org-apache-sling-jcr-resource/pull/36

> ValueMap.get() with null defaultValue not working
> -------------------------------------------------
>
>                 Key: SLING-11567
>                 URL: https://issues.apache.org/jira/browse/SLING-11567
>             Project: Sling
>          Issue Type: Bug
>          Components: JCR
>            Reporter: Joerg Hoh
>            Priority: Blocker
>             Fix For: JCR Resource 3.2.2
>
>
> While checking the current state of the JCR Bundle resource bundle against an existing codebase, I found that it throws errors like this:
> {noformat}
> 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]
> {noformat}
> 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.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)