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/05 08:17:57 UTC

[sling-org-apache-sling-resourceresolver] 01/01: 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 feature/SLING-10844
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git

commit 9aab80f9a08d74a3fcd75965e1522a72ee7d2db2
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));