Hi,
We have various classes annotated with javax.annotation.concurrent.ThreadSafe and javax.annotation.concurrent.Immutable. These annotations are not recognized before raising issue
'Non-primitive fields should not be “volatile” (java:S3077).
Thanks,
Wiraj
Hey @wbibile
Your report is a bit light in information. Can I suggest you look at the following post, and add more details?
https://community.sonarsource.com/t/how-to-report-a-false-positive/37022/3
We are using SonarQube developer edition
SonarQube: server 8.4.2
SonarScanner: 4.4.0.2170
Language: Java
We noticed that SonarQube analysis fails with S3077, for volatile fields whose types are immutable or thread-safe class.
For example:
@javax.annotation.concurrent.Immutable
class MyImmutable
{
....
}
@javax.annotation.concurrent.ThreadSafe
class MyThreadSafe
{
....
}
class Main
{
private volatile MyImmutable x;
private volatile MyThreadSafe y;
}
I don’t expect a warning about ‘Non-primitive fields should not be “volatile”’ for fields Main.x and Main.y as they are marked immutable or thread-safe.
Hello @wbibile,
Thanks for your feedback. Indeed this makes sense to not report in such cases. Created a ticket for it:
https://jira.sonarsource.com/browse/SONARJAVA-3804
Regards,
Margarita
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.