Resource Resolver in SlingPostProcessor

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Resource Resolver in SlingPostProcessor

Sabyasachi Mukherjee
Hi All,

I was playing around with SlingPostProcessor and found an use case where I
am getting the ResourceResolver from the request in process() method of my
custom implementation of SlingPostProcessor and using it for some API calls.

I am curious to know if we should close the RR if its alive?

As the documentation[0] says, "After the operation has performed its
changes but before the changes are persistet, all post processors are
called." , will there be any problem while persisting changes if I close
the RR in my custom PostProcessor and what is the best practice?


[0]
https://sling.apache.org/apidocs/sling7/org/apache/sling/servlets/post/SlingPostProcessor.html

Thanks,
Sabya
Reply | Threaded
Open this post in threaded view
|

Re: Resource Resolver in SlingPostProcessor

Jörg Hoh
Hi,

do not close it. This basic rule of thumb applies here as well: "If you
open a ResourceResolver, you close it". And the contrary as well: "If you
get passed an already open ResourceResolver, do not close it".


2017-08-24 22:51 GMT+02:00 Sabyasachi Mukherjee <[hidden email]>:

> Hi All,
>
> I was playing around with SlingPostProcessor and found an use case where I
> am getting the ResourceResolver from the request in process() method of my
> custom implementation of SlingPostProcessor and using it for some API
> calls.
>
> I am curious to know if we should close the RR if its alive?
>
> As the documentation[0] says, "After the operation has performed its
> changes but before the changes are persistet, all post processors are
> called." , will there be any problem while persisting changes if I close
> the RR in my custom PostProcessor and what is the best practice?
>
>
> [0]
> https://sling.apache.org/apidocs/sling7/org/apache/sling/servlets/post/
> SlingPostProcessor.html
>
> Thanks,
> Sabya
>



--
Cheers,
Jörg Hoh,

http://cqdump.wordpress.com
Twitter: @joerghoh
Reply | Threaded
Open this post in threaded view
|

Re: Resource Resolver in SlingPostProcessor

Sabyasachi Mukherjee
That makes sense. Thanks Jörg !

- Sabya



On Thu, Aug 24, 2017 at 11:14 PM, Jörg Hoh <[hidden email]> wrote:

> Hi,
>
> do not close it. This basic rule of thumb applies here as well: "If you
> open a ResourceResolver, you close it". And the contrary as well: "If you
> get passed an already open ResourceResolver, do not close it".
>
>
> 2017-08-24 22:51 GMT+02:00 Sabyasachi Mukherjee <[hidden email]>:
>
> > Hi All,
> >
> > I was playing around with SlingPostProcessor and found an use case where
> I
> > am getting the ResourceResolver from the request in process() method of
> my
> > custom implementation of SlingPostProcessor and using it for some API
> > calls.
> >
> > I am curious to know if we should close the RR if its alive?
> >
> > As the documentation[0] says, "After the operation has performed its
> > changes but before the changes are persistet, all post processors are
> > called." , will there be any problem while persisting changes if I close
> > the RR in my custom PostProcessor and what is the best practice?
> >
> >
> > [0]
> > https://sling.apache.org/apidocs/sling7/org/apache/sling/servlets/post/
> > SlingPostProcessor.html
> >
> > Thanks,
> > Sabya
> >
>
>
>
> --
> Cheers,
> Jörg Hoh,
>
> http://cqdump.wordpress.com
> Twitter: @joerghoh
>