You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by re...@apache.org on 2025/05/21 12:56:20 UTC

(sling-org-apache-sling-resourceresolver) 01/01: SLING-12795: align behavior for cached ('optimized') and non-cached case

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

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

commit 715856b9ddf62831c2b00fddb08ae7d08b645336
Author: Julian Reschke <ju...@gmx.de>
AuthorDate: Wed May 21 13:56:00 2025 +0100

    SLING-12795: align behavior for cached ('optimized') and non-cached case
---
 .../impl/mapping/AliasHandler.java                 |  7 +++++-
 .../impl/mapping/ResourceMapperImplTest.java       | 28 +++++-----------------
 2 files changed, 12 insertions(+), 23 deletions(-)

diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/mapping/AliasHandler.java b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/AliasHandler.java
index da158284..0188a74a 100644
--- a/src/main/java/org/apache/sling/resourceresolver/impl/mapping/AliasHandler.java
+++ b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/AliasHandler.java
@@ -362,7 +362,12 @@ class AliasHandler {
             Map<String, Map<String, Collection<String>>> localMap = new HashMap<>();
             List<String> throwAwayDiagnostics = new ArrayList<>();
             for (Resource child : parent.getChildren()) {
-                loadAlias(child, localMap, throwAwayDiagnostics, throwAwayDiagnostics);
+                Resource jcrContentChild = child.getChild("jcr:content");
+                loadAlias(
+                        jcrContentChild == null ? child : jcrContentChild,
+                        localMap,
+                        throwAwayDiagnostics,
+                        throwAwayDiagnostics);
             }
             result = localMap.get(parent.getPath());
         }
diff --git a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImplTest.java b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImplTest.java
index c0fb7214..267ae4a8 100644
--- a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImplTest.java
+++ b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImplTest.java
@@ -253,33 +253,17 @@ public class ResourceMapperImplTest {
     /**
      * Validates that a jcr:content resource cannot be aliased, but instead its parent resource is
      *
-     * NOTE: There is a bug in this behavior:
-     * * if optimiseAliasResolution is true, the behavior is working as expected
-     * * if optimiseAliasResolution is false the aliasing is not working
-     *
-     * This bug exists for quite some time (and therefore should be considered a feature by now), so
-     * this test expects different outcome in this case. Also see SLING-12025
-     *
      * @throws LoginException
      */
     @Test
     public void mapJcrContentResourceWithAlias() {
 
-        if (this.optimiseAliasResolution) {
-            ExpectedMappings.existingResource("/content1/jcr:content")
-                    .singleMapping("/jcr:content-alias/jcr:content")
-                    .singleMappingWithRequest("/app/jcr:content-alias/jcr:content")
-                    .allMappings("/jcr:content-alias/jcr:content", "/content1/jcr:content")
-                    .allMappingsWithRequest("/app/content1/jcr:content", "/app/jcr:content-alias/jcr:content")
-                    .verify(resolver, req);
-        } else {
-            ExpectedMappings.existingResource("/content1/jcr:content")
-                    .singleMapping("/content1/jcr:content")
-                    .singleMappingWithRequest("/app/content1/jcr:content")
-                    .allMappings("/content1/jcr:content")
-                    .allMappingsWithRequest("/app/content1/jcr:content")
-                    .verify(resolver, req);
-        }
+        ExpectedMappings.existingResource("/content1/jcr:content")
+                .singleMapping("/jcr:content-alias/jcr:content")
+                .singleMappingWithRequest("/app/jcr:content-alias/jcr:content")
+                .allMappings("/jcr:content-alias/jcr:content", "/content1/jcr:content")
+                .allMappingsWithRequest("/app/content1/jcr:content", "/app/jcr:content-alias/jcr:content")
+                .verify(resolver, req);
     }
 
     /**