Currently stuck on code scanning part of Cloud Manager where my projects fails to build due to SonarQube errors
I'm currently trying to get around the following error:
Usage of com.day.cq.tagging.TagManager as a field is not thread safe.
It states that TagManager object should not be used in Servlets/Filters however I'm getting this error while being used in a component/service.
Official SonarQube DOC (AEM-3): https://github.com/wttech/AEM-Rules-for-SonarQube#rule-set
Here is my implementations:
@component
public class SomeServiceImpl implements SomeService {
...
private TagManager tagManager;
...
public String someFunction () {
try{
tagManager = resourceResolver.adaptTo(TagManager.class);
...
do tagManager methods
...
catch(RepositoryException e){
...
}
}
I even tried declaring TagManager object locally within a function rather than as a class field and still get same SonarQube error.
What is the best practice on handling this object within a Component/Service?