ReturnFromFinallyBlock

Avoid returning from a finally block - this can discard exceptions.

This rule is defined by the following XPath expression:


//FinallyStatement//ReturnStatement

              

Example:

                
  
public class Bar {
 public String foo() {
  try {
   throw new Exception( "My Exception" );
  } catch (Exception e) {
   throw e;
  } finally {
   return "A. O. K."; // Very bad.
  }
 }
}