Throw From Finally Block
ID |
java.throw_from_finally_block |
Severity |
high |
Remediation Complexity |
trivial |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Reliability |
Language |
Java |
Tags |
CWE:584, reliability |
Rationale
A throw inside a finally block replaces whatever exception was propagating from the try or catch block. This means the original failure is silently discarded and can never be caught or logged, making production incidents extremely difficult to diagnose.
// Bad - throw in finally discards the original exception
try {
processFile(path);
} finally {
throw new RuntimeException("cleanup failed");
}