reschke commented on PR #178: URL: https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/178#issuecomment-2893783148
ok, with the only diff from master... ``` diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImpl.java b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImpl.java index 2366ebc..b314df5 100644 --- a/src/main/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImpl.java +++ b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImpl.java @@ -233,8 +233,9 @@ public class ResourceMapperImpl implements ResourceMapper { private void resolveAliases(Resource res, PathGenerator pathBuilder) { String path = res.getPath(); + Resource current = res; - while (path != null) { + while (path != null && current != null) { Collection<String> aliases = Collections.emptyList(); // read alias only if we can read the resources and it's not a jcr:content leaf if (!path.endsWith(ResourceResolverImpl.JCR_CONTENT_LEAF)) { @@ -243,9 +244,15 @@ public class ResourceMapperImpl implements ResourceMapper { // build the path from the name segments or aliases pathBuilder.insertSegment(aliases, ResourceUtil.getName(path)); path = ResourceUtil.getParent(path); + if ("/".equals(path)) { path = null; + } else if (current.getParent() == null) { + throw new RuntimeException("current.getParent() == null for " + current.getClass() + + ", while current.getPath() == " + current.getPath()); } + + current = current.getParent(); } } ``` I get... ``` [ERROR] Errors: [ERROR] MockedResourceResolverImplTest.testMapping:660 » Runtime current.getParent() == null for class org.apache.sling.api.resource.Resource$MockitoMock$tZqPZmm6, while current.getPath() == /single/test ``` So it seems the mocked resource is broken - but it's generated in sling.api. -- 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: dev-unsubscr...@sling.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org