I am dealing with unclosed resource resolver warnings and working on solutions to fix this. In the process I came across this article - https://experienceleague.adobe.com/en/docs/experience-cloud-kcs/kbarticles/ka-23761#
This article offers the following workaround:
The solution seems to close the resource resolver from just one resource instead of "iterating" over the iterator.
For eg:
//workaround: close internal resource resolver(s)
Iterator< Resource> resources = result.getResources();
while (resources.hasNext()) {
Resource resource = resources.next();
resource.getResourceResolver().close();
}
Appreciate your suggestions!!
PS: Tried to use the "suggest an edit" option on that page and got a 404.
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
hi @tatvam,
Each hit.getResource().getResourceResolver() returns the same ResourceResolver instance (the leaking one). Closing a ResourceResolver multiple times would cause errors, so you only need to close it once to fix the leak.
The code here also correctly uses resourceResolver.getResource(hit.getPath()) (the resolver passed into the method) when collecting resources to return, rather than using hit.getResource() directly. This ensures you're working with resources from a resolver you control, not the one that's about to be closed (this is a defensive pattern to handle a QueryBuilder implementation bug).
hi @tatvam,
Each hit.getResource().getResourceResolver() returns the same ResourceResolver instance (the leaking one). Closing a ResourceResolver multiple times would cause errors, so you only need to close it once to fix the leak.
The code here also correctly uses resourceResolver.getResource(hit.getPath()) (the resolver passed into the method) when collecting resources to return, rather than using hit.getResource() directly. This ensures you're working with resources from a resolver you control, not the one that's about to be closed (this is a defensive pattern to handle a QueryBuilder implementation bug).
Thanks for the response. I think adding this line
Each hit.getResource().getResourceResolver() returns the same ResourceResolver instance (the leaking one)
to the KB article will be very helpful. Appreciate if someone could help.
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies