Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

SonarQube Issues - ThreadSafe and finally block

kiranparab
Level 4
Level 4

Hi Team,

 

Issue -

1. Usage of org.apache.sling.api.resource.ResourceResolver as a field is not thread safe.

2. Usage of javax.jcr.Session as a field is not thread safe.

3. ResourceResolver, Session should be closed in finally block.

 

Critical in SonarQube through CloudManager. What is the workaround for this scenario to handle in code. Below code quality documents not talks about the Thread safe scenario.

 

We are using serviceUser and we are taking serviceResourceResolver and there is no pointer how to resolve those scenario's.

 

If we close the resourceResolver and Session then it will not work as expected.

 

Reference -
https://experienceleague.adobe.com/docs/experience-manager-cloud-service/implementing/using-cloud-ma...

 

Thanks,
Kiran Parab

1 Accepted Solution
snbaem
Correct answer by
Community Advisor
Community Advisor

Are your service user based resolvers operated within a try-with-resources block? https://cqdump.joerghoh.de/2018/11/14/try-with-resource-or-i-will-never-forget-to-close-a-resource-r...

 

request resolvers and session resolvers need not be closed. Also curios if adding @SuppressWarnings annotation helps..

View solution in original post

1 Reply
snbaem
Correct answer by
Community Advisor
Community Advisor

Are your service user based resolvers operated within a try-with-resources block? https://cqdump.joerghoh.de/2018/11/14/try-with-resource-or-i-will-never-forget-to-close-a-resource-r...

 

request resolvers and session resolvers need not be closed. Also curios if adding @SuppressWarnings annotation helps..

View solution in original post