[
https://issues.apache.org/jira/browse/SLING-7508?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16377597#comment-16377597
]
ASF GitHub Bot commented on SLING-7508:
---------------------------------------
justinedelson closed pull request #4: SLING-7508: fixed endless recursion
getModelClassForResource()
URL: https://github.com/apache/sling-org-apache-sling-models-impl/pull/4
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/src/main/java/org/apache/sling/models/impl/AdapterImplementations.java
b/src/main/java/org/apache/sling/models/impl/AdapterImplementations.java
index 3ee2fa5..8bac535 100644
--- a/src/main/java/org/apache/sling/models/impl/AdapterImplementations.java
+++ b/src/main/java/org/apache/sling/models/impl/AdapterImplementations.java
@@ -319,7 +319,11 @@ public void removeResourceTypeBindings(final Bundle
bundle) {
}
}
Resource resourceTypeResource =
resolver.getResource(originalResourceType);
- return getModelClassForResource(resourceTypeResource, map);
+ if (resourceTypeResource != null &&
!resourceTypeResource.getPath().equals(resource.getPath())) {
+ return getModelClassForResource(resourceTypeResource, map);
+ } else {
+ return null;
+ }
}
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> StackOverflowError adapting ServletResource to Sling Model 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.2
> Reporter: Dirk Rudolph
> Assignee: Justin Edelson
> Priority: Major
> Fix For: Sling Models Impl 1.4.8
>
>
> 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}
> @SlingServlet(paths = "/apps/mypath")
> 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}
> See the example here:
> https://github.com/Buuhuu/sling-org-apache-sling-models-integration-tests/commit/db174f7a8d43432e4445f4e0aa90487827f66f72
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)