diff --git a/java-checks/src/main/resources/org/sonar/l10n/java/rules/squid/S1143.html b/java-checks/src/main/resources/org/sonar/l10n/java/rules/squid/S1143.html index a924a462f1b..c970fa89151 100644 --- a/java-checks/src/main/resources/org/sonar/l10n/java/rules/squid/S1143.html +++ b/java-checks/src/main/resources/org/sonar/l10n/java/rules/squid/S1143.html @@ -1,6 +1,7 @@ -
Returning from a finally
block suppresses the propagation of any unhandled Throwable
which was thrown in the try
or catch
block.
return
ing, break
ing, throw
ing, and so on from a finally
block suppresses the propagation of any unhandled Throwable
which was thrown in the try
or catch
block.
This rule raises an issue when a jump statement (break
, continue
, return
, throw
, and goto
) would force control flow to leave a finally
block.
public static void main(String[] args) { try { @@ -15,6 +16,13 @@-Noncompliant Code Example
try { throw new RuntimeException(); } finally { + for (int i = 0; i < 10; i ++) { + //... + if (q == i) { + break; // ignored + } + } + /* ... */ return; // Noncompliant - prevents the RuntimeException from being propagated } @@ -36,12 +44,21 @@Compliant Solution
try { throw new RuntimeException(); } finally { + for (int i = 0; i < 10; i ++) { + //... + if (q == i) { + break; // ignored + } + } + /* ... */ } }