joerghoh commented on code in PR #171:
URL:
https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/171#discussion_r2056390674
##########
src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java:
##########
@@ -928,20 +928,21 @@ private Resource getChildInternal(final Resource parent,
final String childName)
// 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 {} in {}",
+ 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();
Review Comment:
can't you use ``parentPath`` here as well?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]