False Positive java:S1143 Return in Finally Block

Language: Java
Rule: S1143
System: SonarQube Developer 9.9.1

Reporting a return statement from a finally block, but return is associated with a lambda function within the block, not returning from the block itself.

I notice that this has been raised before, 4 years ago in Feb 2019 under “False positive S1143 reports return inside lambda function”.


try {
  // Do some work
} finally {
  // Call a method that takes a lambda, e.g. updating a map using computeIfPresent
  map.computeIfPresent(key, (existingKey, existingValue) -> {
    // This is the 'return' that triggers the false positive, but it simply removes the entry from the map.
    // It is not returning from the finally block, but rather from the lambda.
    return null;
1 Like

Hey there.

What version of SonarQube are you using?

Updated, its 9.9.1.

Hello @sball, welcome to Sonar Community!

Thank you for reporting this catchy false positive. I verified the issue and created a ticket to fix it, you can check the progress on the resolution by checking SONARJAVA-4619.


1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.