You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2022/08/08 13:10:54 UTC

[sling-org-apache-sling-resourceresolver] branch master updated: SLING-10844 - ResourceMapper.getMapping() returns null for empty path

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git


The following commit(s) were added to refs/heads/master by this push:
     new 5385d6b  SLING-10844 - ResourceMapper.getMapping() returns null for empty path
5385d6b is described below

commit 5385d6bb0400f2131350c6a59ca437c5a371dd0b
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Aug 5 11:16:41 2022 +0300

    SLING-10844 - ResourceMapper.getMapping() returns null for empty path
    
    The final effort to return at least one mapped path should handle the case when the user does
    not have read access to the root path.
---
 .../sling/resourceresolver/impl/mapping/ResourceMapperImpl.java      | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImpl.java b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImpl.java
index d3de98b..ab1f6f3 100644
--- a/src/main/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImpl.java
+++ b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImpl.java
@@ -163,8 +163,9 @@ public class ResourceMapperImpl implements ResourceMapper {
         mappings.addAll(0, vanityPaths);
 
         // 7. final effort to make sure we have at least one mapped path
-        if ( mappings.isEmpty() && nonDecoratedResource != null )
-            mappings.add(nonDecoratedResource.getPath());
+        if ( mappings.isEmpty() ) {
+            mappings.add(nonDecoratedResource != null ? nonDecoratedResource.getPath() : "/");
+        }
 
         // 8. apply context path if needed
         mappings.replaceAll(new ApplyContextPath(request));