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

Mohit Arora commented on SLING-10844:
-------------------------------------

[~AdityaSeth] The behavior was changed with commit [0] which was accompanied by 
a UT which states that for empty resource path, mappings contain the root path. 
That's true when the resolver used has read access to root path. But for a 
serviceuser which does not have the read permissions on root, null is returned. 
I am not sure of the motivation for this change but it seems it was mostly done 
as optimization.

{quote}This also makes check [2] and following line redundant so we. can remove 
them as well{quote}

getMappings API does not promise a nonNull return value. Is there a possibility 
mappings can be null?

I would suggest to raise a PR with the proposed change.

[0] 
https://github.com/apache/sling-org-apache-sling-resourceresolver/commit/70e3dd11679fa5188920e9785293091b81a840ea#diff-a1b5b745ef3d187ffdbbcaad6d4d03593ddc4f849aae2d959cae043172cd159d

> ResourceMapper.getMapping() returns null for empty path
> -------------------------------------------------------
>
>                 Key: SLING-10844
>                 URL: https://issues.apache.org/jira/browse/SLING-10844
>             Project: Sling
>          Issue Type: Bug
>          Components: ResourceResolver
>    Affects Versions: Resource Resolver 1.7.0
>            Reporter: Mohit Arora
>            Priority: Major
>             Fix For: Resource Resolver 1.7.12
>
>
> After the bug fix for SLING-9620, the behavior for 
> ResourceMapper.getAllMappings() was changed such that the mappings list 
> remains empty if the resourcePath provided is an empty string. Prior to this 
> bug fix, the mappings list contained a single entry for empty path.
> Since mappings list is empty, [ResourceMapper.getMapping() returns 
> null|https://github.com/apache/sling-org-apache-sling-resourceresolver/blob/master/src/main/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImpl.java#L74-L75].
>  The [javadoc of 
> ResourceMapper.getMapping()|https://github.com/apache/sling-org-apache-sling-api/blob/master/src/main/java/org/apache/sling/api/resource/mapping/ResourceMapper.java#L67]
>  API mentions that it will return a non null value if the resourcepath is not 
> null.
> We need to decide on the expected behavior here. If mappings list should not 
> be updated in case of empty resourcePath then the API annotation will have to 
> be changed and it can potentially be a backwards incompatible issue in theory 
> as the consumers of the API may not have added a null check to the return 
> value.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to