Version 4.5.x is more than 5 years old, a lot happened since then!
More specifically, my guess is that the change you are looking for is: SONARJAVA-2569.
The idea is that in order to remove noise, this rule triggers an issue only when the class contains a synchronized method. It is also stated in the rule description.
Hi @Quentin
I didnât notice that description of rule was updated.
For our case old behaviour of the rule was completely correct and helped us spot issues.
After the change rule seams useless.
I donât understand why rule now requires an other synchronised method to treat class as multithread class.
Example class is valid multithread, issue would be here if two threads would do Test.getPreferences().get(âloadingâ), there could be a race when one thread passes null check and other would get half initialised fPreferences field.
Can you point me out to discussion that lead to changes in this rule? Jira link doesnât have much information.
I did not manage to find the discussion related to this change either. My guess is that we have to know when we are in a multi-threaded context, without this restriction, the rule generates too many issues, the real problems will be hidden amongst false positives.
That being said, I kind of agree that it seems a bit too restrictive, however, I am not sure how we can do better in this situation, without being too noisy.
Thanks for reply.
I wanted to see full discussion to get more context about what type of noise that rule generated.
For us how this rule behaviour was correct and I believe that other people would also benefit from it. If rule generates too much noise for code base that doesnât have multi thread use maybe there should be configuration option for it âis code base multi threadâ or similar.
Can you still have configuration options for rules?
After reviewing the whole situation, I agree that there is something to improve for this rule, and relaxing the constraint to have a synchronized method seems to be the best way to go.
I created a ticket (SONARJAVA-3802) summarizing the situation, could you have a look at it and tell me if it makes sense to you?