[
https://issues.apache.org/jira/browse/SLING-2457?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13532429#comment-13532429
]
Alexander Klimetschek edited comment on SLING-2457 at 12/14/12 4:38 PM:
------------------------------------------------------------------------
I have a problem with this change with the Resource.isResourceType()
implementation in a custom Resource. It calls ResourceUtil.isA() to do the job,
which now results in a recursive call and a stack overflow.
To solve that, I can implement something like this - I guess that's the
intention:
public boolean isResourceType(String type) {
return localType.equals(type) || getParent().isResourceType(type);
}
Note that in this case I don't extend from AbstractResource because the class
already extends from SlingAdaptable (which I guess is common for Resources). I
also cannot reuse ResourceUtil.internalIsA() as the AbstractResource does as
it's package-private.
However, I am not sure if the change to isA() is right:
* it's a backwards compatibility issue
* the authority of how resource type inheritance works is now moved from a
de-facto single place (ResourceUtil.isA()) to the resource itself, which might
mess it up
was (Author: alexander.klimetschek):
I have a problem with this change with the Resource.isResourceType()
implementation in a custom Resource. It calls ResourceUtil.isA() to do the job,
which now results in a recursive call and a stack overflow.
To solve that, I can implement something like this - I guess that's the
intention:
public boolean isResourceType(String type) {
return localType.equals(type) || getParent().isResourceType(type);
}
However, I am not sure if the change to isA() is right:
* it's a backwards compatibility issue
* the authority of how resource type inheritance works is now moved from a
de-facto single place (ResourceUtil.isA()) to the resource itself, which might
mess it up
> ResourceUtil.isA() fails if resource has a type, whose super type is not
> readable
> ---------------------------------------------------------------------------------
>
> Key: SLING-2457
> URL: https://issues.apache.org/jira/browse/SLING-2457
> Project: Sling
> Issue Type: Bug
> Components: API
> Affects Versions: API 2.2.0
> Reporter: Tyson Norris
> Assignee: Carsten Ziegeler
> Fix For: Servlets Resolver 2.2.0, API 2.3.0
>
>
> * define a resource at /content/component/foo whose type is
> myapp/components/bar
> * define bar at /apps/myapp/components/bar
> * on /apps/myapp/components/bar, set sling:resourceSuperType as
> /libs/components/bar2
> If resolver from resource.getResourceResolver() cannot access
> /libs/components/bar2, then ResouceUtil.isA(resource, "components/bar2")
> returns false, otherwise it returns true.
> There could be an argument that it should not return true in any case,
> however, if you set resourceSuperType on resource as "components/bar2", then
> it returns true with current implementation.
> At least one of these is wrong, I think.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira