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

ResourceDecorator returning null should cause Resources to be ignored

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Won't Fix
    • Resource Resolver 1.0.6
    • None
    • ResourceResolver
    • None

    Description

      The ResourceDecorator API's decorate(...) method javadocs currently specify that it can return null, but I don't think that's supported in a consistent way in the resource resolving process - returning null causes the resource resolver to supply a null Resource in some cases, which will probably cause NPEs downstream.

      The javadocs also say "If the service does not want to decorate the resource, it should return the original resource" which is consistent with how the resource resolver currently operates: returning null is clearly not a way of saying "do not decorate this resource".

      As we're discussing feature flags in Sling, we could clarify this behavior by specifying that a ResourceDecorator returning null causes the resource to be considered as non-existent, and making the corresponding (rather small) changes in the resource resolver code.

      As every Resource needs to go through the available ResourceDecorators, this is a simple way of making resources hideable based on feature flags. One then just needs to implement a ResourceDecorator that returns null when a Resource must be ignored.

      Attachments

        1. SLING-3267.patch
          17 kB
          Bertrand Delacretaz

        Issue Links

          Activity

            People

              bdelacretaz Bertrand Delacretaz
              bdelacretaz Bertrand Delacretaz
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: