[
https://issues.apache.org/jira/browse/SLING-2780?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13674491#comment-13674491
]
Alexander Klimetschek commented on SLING-2780:
----------------------------------------------
With this change and a custom, wrapping ResourceProvider I now get an exception
"ResourceMetadata is locked" when requesting that resource (/overlay/foo) in a
GET request (see below). The exception happens during sling's request
initialization phase. My custom provider does wrap resources from another
location/provider, which are accessed through the ResourceResolver. The safe
and right solution seems to wrap the metadata object:
ResourceMetadata metadata = new ResourceMetadata();
metadata.putAll(getResource().getResourceMetadata());
But I just want to point out that this might break some existing resource
providers. And the question is if resource decorators are safe.
GET /overlay/foo HTTP/1.1]
org.apache.sling.engine.impl.SlingRequestProcessorImpl service: Uncaught
Throwable java.lang.UnsupportedOperationException: ResourceMetadata is locked
at
org.apache.sling.api.resource.ResourceMetadata.checkReadOnly(ResourceMetadata.java:310)
at
org.apache.sling.api.resource.ResourceMetadata.put(ResourceMetadata.java:322)
at
org.apache.sling.api.resource.ResourceMetadata.setResolutionPath(ResourceMetadata.java:254)
at
org.apache.sling.resourceresolver.impl.ResourceResolverImpl.getResourceInternal(ResourceResolverImpl.java:916)
at
org.apache.sling.resourceresolver.impl.ResourceResolverImpl.getChildInternal(ResourceResolverImpl.java:872)
at
org.apache.sling.resourceresolver.impl.ResourceResolverImpl.resolveInternal(ResourceResolverImpl.java:819)
at
org.apache.sling.resourceresolver.impl.ResourceResolverImpl.resolve(ResourceResolverImpl.java:319)
at
org.apache.sling.engine.impl.request.RequestData.initResource(RequestData.java:208)
at
org.apache.sling.engine.impl.SlingRequestProcessorImpl.processRequest(SlingRequestProcessorImpl.java:140)
at
org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:206)
> Make ResourceMetadata read-only when delivered to client code
> -------------------------------------------------------------
>
> Key: SLING-2780
> URL: https://issues.apache.org/jira/browse/SLING-2780
> Project: Sling
> Issue Type: New Feature
> Components: API, ResourceResolver
> Affects Versions: API 2.3.0, Resource Resolver 1.0.4
> Reporter: Carsten Ziegeler
> Assignee: Carsten Ziegeler
> Fix For: API 2.4.0, Resource Resolver 1.0.6
>
>
> As recently discussed in the mailing list, ResourceMetadata is an object
> which provides additional metadata information about a resource but is not
> intended to be changed by client code.
> As ResourceMetadata extends from (Hash)Map it is read/write by default and
> might potentially be changed by client code.
> We should update the API docs that this object is read-only and also enforce
> it in our implementation.
> It seems so far no one is changing the ResourceMetadata after it has left the
> resource resolver, therefore we can make it read-only after it is returned by
> the resource resolver.
--
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