Expand my Community achievements bar.

SOLVED

Does the ResourceResolverFactory create a thread safe ResourceResolver?

Avatar

Level 2

I need a thread safe ResourceResolver that can be used for CRUD operations but nothing says using the ResourceResolverFactory is or isn't thread safe.

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor
ResourceResolver is as stated not thread safe, therefore it should not
be used concurrently by different threads. However, if you create the
resource resolver through the factory yourself you can pass it on to
another thread.

Reference : https://www.mail-archive.com/users@sling.apache.org/msg03803.html  



Arun Patidar

View solution in original post

3 Replies

Avatar

Community Advisor

Hi @Art_Bird 

ResourceResolver is generally not thread safe! As a consequence, an application which uses the resolver, its returned resources and/or objects resulting from adapting either the resolver or a resource, must provide proper synchronization to ensure no more than one thread concurrently operates against a single resolver, resource or resulting objects. Please check below links for more info. 

https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/org/apache/sling/api/... 

https://kiransg.com/2021/11/07/aem-resource-resolver-commit-save-best-practices/ 

Avatar

Level 2

I understand the ResourceResolver isn't thread safe.

 

My question is a ResourceResolver that has been created using the ResourceResolverFactory considered thread safe?

Avatar

Correct answer by
Community Advisor
ResourceResolver is as stated not thread safe, therefore it should not
be used concurrently by different threads. However, if you create the
resource resolver through the factory yourself you can pass it on to
another thread.

Reference : https://www.mail-archive.com/users@sling.apache.org/msg03803.html  



Arun Patidar