SonarQube fails to detect an infinite loop involving AtomicBoolean

  • What language is this for?
    • Java
  • Which rule?
  • Why do you believe it’s a false-positive/false-negative?
    • In the following minimized code example, SonarQube should report a warning at line 3, as this is clearly an infinite loop.
  • Are you using
    • SonarQube Server / Community Build - 25.6.0
  • How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)

Code Example

import java.util.concurrent.atomic.AtomicBoolean;

public class Main {
    public static void main(String[] args) {
        AtomicBoolean _validConnection = new AtomicBoolean(false);
        while (!_validConnection.get()) { // should report a warning at this line, but no warnings
            // ...
        }
    }
}

Hi @Belle !

Thank you for reporting this shortcoming in the analysis and for providing this concise example!

I can confirm that the analyzer is not raising an issue for it even though this is indeed an infinite loop. I have created a ticket to track the problem: Jira

1 Like