- S2583 False Positive (“Conditionally executed code should be reachable”)
- Java (21-tem)
- SonarQube for IDE - eclipse 2026.03, SonarLint 12.2.1, not connected to server
The following code triggers the S2583 for me on the (version != null) part. Apparently it cannot cope with the nested try-catch block.
public class Playground {
public void play() {
String version = null;
try {
var thing = readSomething();
version = thing.version();
try (var stream = thing.stream()) {
doSomething(stream);
}
} catch (Exception e) {
var versionSuffix = (version != null) ? ", version " + version : "";
throw new IllegalStateException("bad" + versionSuffix, e);
}
}
private static Thing readSomething() {
return null;
}
private void doSomething(InputStream rawStream) {
// no-op
}
record Thing(InputStream stream, String version) {}
}