Hi, I found a false positive in SonarQube 9.5.0, please read the following code example.
SonarQube reports that in
is not closed in finally branch. However, @lombok.Cleanup
can generate related statements to help us close in
. Hence, I think this is a false positive.
public static void main(String[] args) throws IOException {
@Cleanup
InputStream in = new FileInputStream(args[0]); // a false positive
byte[] b = new byte[10000];
while (true) {
int r = in.read(b);
if (r == -1)
break;
}
}