[
https://issues.apache.org/jira/browse/SLING-7508?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16371918#comment-16371918
]
Dirk Rudolph commented on SLING-7508:
-------------------------------------
As far as I can see the issue is caused by the
[ResourceTypeBasedResourcePicker.java#L46|https://github.com/apache/sling-org-apache-sling-models-impl/blob/master/src/main/java/org/apache/sling/models/impl/ResourceTypeBasedResourcePicker.java#L46]
calling [AdapterImplementations#getModelClassForResource()|
https://github.com/apache/sling-org-apache-sling-models-impl/blob/master/src/main/java/org/apache/sling/models/impl/AdapterImplementations.java#L321]
which walks up the resourceType hierarchy until it finds an implementation.
For the SerlvetResource in that case the resourceSuperTypes are
"sling/bundle/resource" and null, so it ends up getting the resource of the
originalResourceType of the ServletResource which is again the ServletResource
causing the endless loop.
> StackOverflowError adapting ServletResource to Sling Mode with impl picker
> --------------------------------------------------------------------------
>
> Key: SLING-7508
> URL: https://issues.apache.org/jira/browse/SLING-7508
> Project: Sling
> Issue Type: Bug
> Components: Extensions
> Affects Versions: Sling Models Impl 1.4.8
> Reporter: Dirk Rudolph
> Priority: Major
>
> Adapting a {{SlingHttpServletRequest}} to a servlet that is registered using
> sling.servlet.paths to a {{@Model}} fails in the following StackOverflowError:
> {code}
> java.lang.StackOverflowError: null
> ...
> 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)
> {code}
> See for example the following pseudo code:
> {code}
> class MyServlet extends SlingSafeMethodsServlet {
> doGet(request) { request.adaptTo(Model.class); }
> }
> interface Model {
> ...
> }
> @Model(adaptables = SlingHttpServletRequest.class, adapters =
> {ModelImpl.class, Model.class})
> class ModelImpl implements Model {
> ...
> }
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)