Hi

In AEM 6.4.0 load 20 they use a version of org.apache.sling.models.impl 
(1.4.7…).

Using a Content Fragment the loopup for a Model fails and then we end up in an 
endless loop
because the 
org.apache.sling.models.impl.AdapterImplementations.getModelClassForResource()
is looked up with a resource that points to /index.servlet. The resource type 
of that is /index.servlet
leading to an endless loop.

Looking at the code there should be a way to exit in erroneous conditions like 
this one. The is
also the chance that a parent resource type points back to a child (not sure if 
that is possible)
which would also cause an endless loop.

For starters a check if the resource type resource is not posting to the same 
resource as the
given resource before calling the method again would at least guard against 
issues were the
resource type is the same as the resource.

Most likely there is something going wrong beforehand but a StackOverflowError 
is not a good thing.

Here is the stack trace:

java.lang.StackOverflowError
        at 
org.apache.jackrabbit.oak.segment.MapRecord.getEntry(MapRecord.java:161)
        at 
org.apache.jackrabbit.oak.segment.MapRecord.getEntry(MapRecord.java:173)
        at 
org.apache.jackrabbit.oak.segment.SegmentNodeState.getChildNode(SegmentNodeState.java:423)
        at 
org.apache.jackrabbit.oak.plugins.memory.MemoryNodeBuilder.<init>(MemoryNodeBuilder.java:143)
        at 
org.apache.jackrabbit.oak.segment.SegmentNodeBuilder.<init>(SegmentNodeBuilder.java:93)
        at 
org.apache.jackrabbit.oak.segment.SegmentNodeBuilder.createChildBuilder(SegmentNodeBuilder.java:148)
        at 
org.apache.jackrabbit.oak.plugins.memory.MemoryNodeBuilder.getChildNode(MemoryNodeBuilder.java:331)
        at 
org.apache.jackrabbit.oak.core.SecureNodeBuilder.<init>(SecureNodeBuilder.java:112)
        at 
org.apache.jackrabbit.oak.core.SecureNodeBuilder.getChildNode(SecureNodeBuilder.java:329)
        at 
org.apache.jackrabbit.oak.core.MutableTree.getTree(MutableTree.java:290)
        at 
org.apache.jackrabbit.oak.core.MutableRoot.getTree(MutableRoot.java:220)
        at 
org.apache.jackrabbit.oak.core.MutableRoot.getTree(MutableRoot.java:69)
        at 
org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.getItem(SessionDelegate.java:442)
        at 
org.apache.jackrabbit.oak.jcr.session.SessionImpl.getItemInternal(SessionImpl.java:167)
        at 
org.apache.jackrabbit.oak.jcr.session.SessionImpl.access$400(SessionImpl.java:82)
        at 
org.apache.jackrabbit.oak.jcr.session.SessionImpl$3.performNullable(SessionImpl.java:229)
        at 
org.apache.jackrabbit.oak.jcr.session.SessionImpl$3.performNullable(SessionImpl.java:226)
        at 
org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.performNullable(SessionDelegate.java:243)
        at 
org.apache.jackrabbit.oak.jcr.session.SessionImpl.getItemOrNull(SessionImpl.java:226)
        at 
com.adobe.granite.repository.impl.CRX3SessionImpl.getItemOrNull(CRX3SessionImpl.java:98)
        at 
org.apache.sling.jcr.resource.internal.helper.jcr.JcrItemResourceFactory.getItemOrNull(JcrItemResourceFactory.java:184)
        at 
org.apache.sling.jcr.resource.internal.helper.jcr.JcrItemResourceFactory.createResource(JcrItemResourceFactory.java:96)
        at 
org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.getResource(JcrResourceProvider.java:320)
        at 
org.apache.sling.resourceresolver.impl.providers.stateful.AuthenticatedResourceProvider.getResource(AuthenticatedResourceProvider.java:135)
        at 
org.apache.sling.resourceresolver.impl.helper.ResourceResolverControl.getResource(ResourceResolverControl.java:227)
        at 
org.apache.sling.resourceresolver.impl.ResourceResolverImpl.getAbsoluteResourceInternal(ResourceResolverImpl.java:1048)
        at 
org.apache.sling.resourceresolver.impl.ResourceResolverImpl.getResourceInternal(ResourceResolverImpl.java:674)
        at 
org.apache.sling.resourceresolver.impl.ResourceResolverImpl.getResource(ResourceResolverImpl.java:628)
        at 
org.apache.sling.resourceresolver.impl.ResourceResolverImpl.getResourceInternal(ResourceResolverImpl.java:685)
        at 
org.apache.sling.resourceresolver.impl.ResourceResolverImpl.getResource(ResourceResolverImpl.java:628)
        at 
org.apache.sling.resourceresolver.impl.helper.ResourceResolverControl.getParentResourceType(ResourceResolverControl.java:733)
        at 
org.apache.sling.resourceresolver.impl.ResourceResolverImpl.getParentResourceType(ResourceResolverImpl.java:1219)
        at 
org.apache.sling.models.impl.AdapterImplementations.getModelClassForResource(AdapterImplementations.java:318)
        at 
org.apache.sling.models.impl.AdapterImplementations.getModelClassForResource(AdapterImplementations.java:322)
        at 
org.apache.sling.models.impl.AdapterImplementations.getModelClassForResource(AdapterImplementations.java:322)



Reply via email to