This is an automated email from the ASF dual-hosted git repository. reschke pushed a commit to branch SLING-12758 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git
commit 7222a9cb371b64324d9e3253f6b154716773e7f8 Author: Julian Reschke <resc...@apache.org> AuthorDate: Wed Apr 23 14:23:39 2025 +0100 SLING-12758: remove redundant check for absolute path in alias --- .../resourceresolver/impl/ResourceResolverImpl.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java b/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java index 6c1a10ad..611d78c8 100644 --- a/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java +++ b/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java @@ -928,20 +928,21 @@ public class ResourceResolverImpl extends SlingAdaptable implements ResourceReso // we do not have a child with the exact name, so we look for // a child, whose alias matches the childName if (factory.getMapEntries().isOptimizeAliasResolutionEnabled()) { - logger.debug("getChildInternal: Optimize Alias Resolution is Enabled"); - // optimization made in SLING-2521 + final String parentPath = parent.getPath(); + logger.debug( + "getChildInternal: Optimize Alias Resolution is Enabled, looking up {} im {}", + childName, + parentPath); + + // optimized alias resolution: aliases are cached by MapEntries final Optional<String> aliasedResourceName = - factory.getMapEntries().getAliasMap(parent.getPath()).entrySet().stream() + factory.getMapEntries().getAliasMap(parentPath).entrySet().stream() .filter(e -> e.getValue().contains(childName)) .findFirst() .map(Map.Entry::getKey); if (aliasedResourceName.isPresent()) { - final String aliasPath; - if (aliasedResourceName.get().startsWith("/")) { - aliasPath = aliasedResourceName.get(); - } else { - aliasPath = parent.getPath() + '/' + aliasedResourceName.get(); - } + // we know that MapEntries already has checked for valid aliases + final String aliasPath = parent.getPath() + '/' + aliasedResourceName.get(); final Resource aliasedChild = getAbsoluteResourceInternal(parent, ResourceUtil.normalize(aliasPath), EMPTY_PARAMETERS, true); logger.debug("getChildInternal: Found Resource {} with alias {} to use", aliasedChild, childName);