Sign in to Community
Sign in to view all badges
We know that binding variables like session - javax.jcr.Session
resourceResolver - org.apache.sling.api.resource.ResourceResolver are available for use in groovy scripts.
We can use this JCR session to execute SQL queries, update node properties.
But, we are not closing JCR Session and ResourceResolver explicitly like session.logout() and resourceResolver.close() in groovy script.
How resourceResolver and session are getting closed automatically in groovy script?
Hi @Debal-Das ,
If you are not opening any resource or session, you don't have to close it
Session and ResourceResolver objects that are obtained via the SlingRequest or WorkflowSession do not close by your application. For example:
That resolver or session closes automatically after the request has been processed.
Hope this helps.
If you are not opening any resource or session, you don't have to close it.
Similar when you get a session from a request or getting PrintWriter from a response, you use it and leave it because you did not open it explicitly.
and you should not close any resource/session if you did not open it.