The documentation of clone clearly states that if "null" is passed in: "the
same credential data is used as was used to create this instance." which in
turn means, if the initlal resolver was created based on a session, this
one will share the session.
So in your case, you have to create a new session and pass this into the
clone method - or you can also call the resource resolver factory directly.

Regards
Carsten


2014-04-24 21:23 GMT+02:00 Alexander Klimetschek <[email protected]>:

> Hi,
>
> I have a case where I need to open a new JCR session / resource resolver
> from an existing one for a task that runs in a separate thread. I am using
> ResourceResolver.clone(null) for that. Documentation gives the impression
> it is a new one (since you assume a 1:1 between resource resolver instance
> and JCR session in general). But it seems the same session is returned.
>
> I can't debug the issue, but looking at the code of the
> JcrResourceProviderFactory [2] it seems that if the original
> AuthenticationInfo is based on a JCR session explicitly passed with
> JcrResourceConstants.AUTHENTICATION_INFO_SESSION, this one will be
> returned. And not cloned through impersonation to itself.
>
> Would it be necessary to explicitly use USER_IMPERSONATION (using the
> current user) on the authInfo?
>
> [1]
> http://sling.apache.org/apidocs/sling6/org/apache/sling/api/resource/ResourceResolver.html#clone(java.util.Map)
> [2]
> http://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderFactory.java
>
> Cheers,
> Alex




-- 
Carsten Ziegeler
[email protected]

Reply via email to