Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-11567

ValueMap.get() with null defaultValue not working

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • None
    • JCR Resource 3.2.2
    • JCR
    • 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.

      Attachments

        Activity

          People

            joerghoh Joerg Hoh
            joerghoh Joerg Hoh
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 3h
                3h