Resource Resolver Leak
Hi All,
We are facing this warning message multiple times in our 6.5.6 AEM environment.
https://helpx.adobe.com/bg/experience-manager/kb/Unclosed-ResourceResolver-warnng-at-com-day-cq-search-impl-builder-QueryBuilderImpl.html
Hi All,
We are facing this warning message multiple times in our 6.5.6 AEM environment.
Hi @user21583!
The INFO level log message that you have posted is a warning mechanism of AEM to bring resource resolvers to your attention that are not correctly handled (specifically: not closed properly). The source of that unclosed resource resolver can usually be spotted in the stack trace that follows. Please refer to the stack trace after "Unclosed ResourceResolver was created here:" in your log file to start your analysis of the root cause of the unclosed resource resolver.
While there have been issues with actual AEM product code not correctly handling and closing resource resolvers in the past (as mentioned in the KB article that you are referencing), I'm not aware of any know issues with latest versions of AEM. In my experience, most of these cases are somehow (directly or indirectly) caused by custom project code. If your analysis points to AEM product code as a source of the improper handling of a resource resolver, please create a support ticket so that our customer care and engineering teams can check.
How to handle resource resolvers correctly?
Please refer to the Sling API and this thread for more information on how to correctly handle (e. g. open and close) resource resolvers.
From the API documentation:
A Resource Resolver has a life cycle which begins with the creation of the Resource Resolver using any of the factory methods and ends with calling the close() method. It is very important to call the close() method once the resource resolver is not used any more to ensure any system resources are properly clean up. |
From the thread (answer by @feike_visser1) :
Follow the rule "You open a resourceResovler / Session, You Close it". If this is not the case, leave it... |
Also, @joerghoh covers this in his blog post on CQ development patterns (see "2nd pattern: Ownership: You open it — you close it.") and as mentioned by @bhuwan_b he recommends to leverage the try-with-resource pattern in another article.
Hope that helps!
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.