Empty Catch Block
ID |
java.empty_catch_block |
Severity |
high |
Remediation Complexity |
trivial |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Reliability |
Language |
Java |
Tags |
CWE:1069, reliability |
Rationale
An empty catch block silently swallows the exception, hiding failures that may lead to incorrect program state, data corruption, or security vulnerabilities. When an exception is ignored without explanation, debugging production incidents becomes extremely difficult because the root cause is never logged.
// Bad - exception is silently swallowed
try {
parseInput(data);
} catch (ParseException e) {
}
Remediation
At a minimum, log the exception. If the exception is genuinely expected and ignorable, add a comment explaining why:
// Good - exception is logged
try {
parseInput(data);
} catch (ParseException e) {
log.warn("Failed to parse input", e);
}