Why this code failed rule java:S2222

try {

  while(!lock.tryLock()) {

    doSomething();

  } finally {

    try {

      lock.unlock();

    }

  }

}

Hi,

Welcome to the community and thanks for this report!

Can you give your context for this? I.e. are you on SonarQube Cloud? SonarQube for IDE (flavor and version)? SonarQube self-managed (flavor and version)?

 
Thx,
Ann

Sonarqube server data center edition 2025.1 (102418)

Sonarqube server data center edition 2025.1 (102418)

Hi,

The current LTA is 2026.1.3 and the latest version is 2026.3. Can you reproduce this on either of those versions?

Your update path is:

2025.1 → 2026.1.3 → 2026.3 (last step optional)

You may find these resources helpful:

 
Thx,
Ann