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/06/05 10:03:30 UTC

(sling-org-apache-sling-resourceresolver) branch SLING-12823 created (now e2e7bb77)

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

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


      at e2e7bb77 SLING-12823: alias refactoring - avoid getting the parent resource when path sufficient

This branch includes the following new commits:

     new e2e7bb77 SLING-12823: alias refactoring - avoid getting the parent resource when path sufficient

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(sling-org-apache-sling-resourceresolver) 01/01: SLING-12823: alias refactoring - avoid getting the parent resource when path sufficient

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit e2e7bb77d5178d95b377bb7ff47d76aabcf025fe
Author: Julian Reschke <re...@apache.org>
AuthorDate: Thu Jun 5 11:03:12 2025 +0100

    SLING-12823: alias refactoring - avoid getting the parent resource when path sufficient
---
 .../impl/mapping/AliasHandler.java                 | 28 +++++++---------------
 1 file changed, 9 insertions(+), 19 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 fb2efff0..4678763e 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
@@ -469,27 +469,17 @@ class AliasHandler {
             log.warn("containingResource is null for alias on {}, skipping.", resource.getPath());
             return false;
         } else {
-            Resource parent = containingResource.getParent();
-
-            if (parent == null) {
-                log.warn(
-                        "{} is null for alias on {}, skipping.",
-                        containingResource == resource ? "parent" : "grandparent",
-                        resource.getPath());
+            String[] aliasArray = resource.getValueMap().get(ResourceResolverImpl.PROP_ALIAS, String[].class);
+            if (aliasArray == null) {
                 return false;
             } else {
-                String[] aliasArray = resource.getValueMap().get(ResourceResolverImpl.PROP_ALIAS, String[].class);
-                if (aliasArray == null) {
-                    return false;
-                } else {
-                    return loadAliasFromArray(
-                            aliasArray,
-                            map,
-                            conflictingAliases,
-                            invalidAliases,
-                            containingResource.getName(),
-                            parent.getPath());
-                }
+                return loadAliasFromArray(
+                        aliasArray,
+                        map,
+                        conflictingAliases,
+                        invalidAliases,
+                        containingResource.getName(),
+                        ResourceUtil.getParent(containingResource.getPath()));
             }
         }
     }