This conversation has been locked due to inactivity. Please create a new post.
This conversation has been locked due to inactivity. Please create a new post.
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?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
Try autoclosable try for resourceResolver. The resource Resolver is also not closed here
Seems like this is a service in which you are using tag manager. Service is a Session based concept. You can create a different class and define the tag logic there and call it in your service implementation and check if its working.
Views
Likes
Replies
Views
Likes
Replies