When to explicitly close ResourceResolver in Sling
<p>I've read on <a href="https://cqdump.wordpress.com/2013/07/23/cq-development-patterns-sling-resourceresolver-and-jcr-sessions/" rel="nofollow noreferrer">this</a> blog about how to use resourceResolver properly. The author quotes</p>
<blockquote>
<p>If you open a JCR session of a Sling ResourceResolver, you are also
responsible for closing it. On the other hand: If you get passed a
ResourceResolver or a Session object, do not call logout() or close()
on it.</p>
</blockquote>
<p>I'm not able to grasp this concept, may be because of no code example in this case.</p>
<p>From what i know, i can get a ResourceResolver object via either request.getResourceResolver() in servlets, using @Reference SCR annotation in OSGi components, jsp's implicit resourceResolver object, using sling.getService() in jsp, and also via adapting to ResourceResolver object.</p>
<p>In all the ways of getting resourceResolver object, which ones should i close myself and what is the session associated with each of these objects ?</p>