Spring has nothing to do with this, what you obtain is a behavior as required by JLS 14.20.2 Execution of try-catch-finally:
A
try
statement with afinally
block is executed by first executing thetry
block. Then there is a choice...
- If execution of the
try
block completes abruptly because of athrow
of a value V, then there is a choice:
If the run-time type of V is assignable to the parameter of anycatch
clause of thetry
statement, then the first (leftmost) suchcatch
clause is selected. The value V is assigned to the parameter of the selectedcatch
clause, and the Block of thatcatch
clause is executed. Then there is a choice...
- If the
catch
block completes abruptly for reason R, then thefinally
block is executed...
In your code snippet, RuntimeException
corresponds to "value V" in above quote.
Exception is thrown and caught in respective catch block, which then "completes abruptly" by re-throwing the exception - that is, throw e
in your snippet corresponds to "reason R" in above quote.
Then, as required by language specification, "finally
block is executed".