From c2ddc76427e89dece75c081bf2bc73442eb3d97f Mon Sep 17 00:00:00 2001 From: Michael Gumowski Date: Mon, 22 Feb 2016 10:57:51 +0100 Subject: [PATCH] SONARJAVA-1546 Update description --- .../sonar/l10n/java/rules/squid/S1143.html | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) 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.

-

Noncompliant Code Example

+

returning, breaking, throwing, 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.

+

Noncompliant Code Example

 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 + } + } + /* ... */ } }
-

See

+

See

+
  • MITRE, CWE-584 - Return Inside Finally Block +
  • CERT, ERR04-J. - Do not complete abruptly from a finally block +
  • +