[JAVA] S2168 Double-checked locking should not be used - False Positive - it doesn't work when an assignment operation is in another method

170 views
Skip to first unread message

Adam Gabryś

unread,
Apr 15, 2018, 2:16:32 PM4/15/18
to SonarQube

Hello,
Adam L hit a false positive in the S2168 rule when an instance is assigned in an other method. He added a post on Stack Overflow https://stackoverflow.com/q/49741933/4944847 (I apologize for cross-posting) and today I finally confirmed that the problem is caused by the rule.

Environment:

  • SonarQube 7.0
  • SonarJava 5.2

Example class:
https://github.com/agabrys/sonarqube-falsepositives/blob/master/src/main/java/biz/gabrys/agabrys/sonarqube/falsepositives/d20180415/S2168.java

Project:
https://github.com/agabrys/sonarqube-falsepositives

Build:
mvn clean package sonar

Regards
Adam Gabryś

adam.l...@gmail.com

unread,
Apr 24, 2018, 11:55:34 AM4/24/18
to SonarQube
Is there a conversation board elsewhere that would address addressing this issue?   Or would it be here?

 I looked at the SQ JIRA, and I don't see anything that resembles what I encountered.

 Thanks !

Andrei Epure

unread,
Jun 11, 2018, 4:00:42 AM6/11/18
to SonarQube
Thank you, Adam.

I'll start a discussion in the dev team, and see if we can do something about this False Negative.

Thank you very much for the effort to put things into github and pin-point the problem.

Regards,
Andrei

Andrei Epure | SonarSource

Software Developer

https://sonarsource.com


Are you using SonarLint in your IDE?


Reply all
Reply to author
Forward
0 new messages