@@ -928,20 +928,21 @@ private Resource getChildInternal(final Resource parent, final String childName)
928
928
// we do not have a child with the exact name, so we look for
929
929
// a child, whose alias matches the childName
930
930
if (factory .getMapEntries ().isOptimizeAliasResolutionEnabled ()) {
931
- logger .debug ("getChildInternal: Optimize Alias Resolution is Enabled" );
932
- // optimization made in SLING-2521
931
+ final String parentPath = parent .getPath ();
932
+ logger .debug (
933
+ "getChildInternal: Optimize Alias Resolution is Enabled, looking up {} in {}" ,
934
+ childName ,
935
+ parentPath );
936
+
937
+ // optimized alias resolution: aliases are cached by MapEntries
933
938
final Optional <String > aliasedResourceName =
934
- factory .getMapEntries ().getAliasMap (parent . getPath () ).entrySet ().stream ()
939
+ factory .getMapEntries ().getAliasMap (parentPath ).entrySet ().stream ()
935
940
.filter (e -> e .getValue ().contains (childName ))
936
941
.findFirst ()
937
942
.map (Map .Entry ::getKey );
938
943
if (aliasedResourceName .isPresent ()) {
939
- final String aliasPath ;
940
- if (aliasedResourceName .get ().startsWith ("/" )) {
941
- aliasPath = aliasedResourceName .get ();
942
- } else {
943
- aliasPath = parent .getPath () + '/' + aliasedResourceName .get ();
944
- }
944
+ // we know that MapEntries already has checked for valid aliases
945
+ final String aliasPath = parentPath + '/' + aliasedResourceName .get ();
945
946
final Resource aliasedChild =
946
947
getAbsoluteResourceInternal (parent , ResourceUtil .normalize (aliasPath ), EMPTY_PARAMETERS , true );
947
948
logger .debug ("getChildInternal: Found Resource {} with alias {} to use" , aliasedChild , childName );
0 commit comments