Unclosed resource resolver | Community
Skip to main content
tatvam
October 27, 2025
Solved

Unclosed resource resolver

  • October 27, 2025
  • 1 reply
  • 270 views

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.

Best answer by giuseppebaglio

 

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).

 

1 reply

giuseppebaglio
giuseppebaglioAccepted solution
New Member
October 27, 2025

 

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).

 

tatvam
tatvamAuthor
October 27, 2025

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.