...
Catching NullPointerException
may mask an underlying null dereference, degrade application performance, and result in code that is hard to understand and maintain. Likewise, catching RuntimeException
, Exception
, or Throwable
may unintentionally trap other exception types and prevent them from being handled properly.
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
ERR08-J | Medium | Likely | Medium | P12 | L1 |
Automated Detection
Tool | Version | Checker | Description |
---|---|---|---|
CodeSonar |
...
| JAVA.STRUCT.EXCP.GEH | Generic Exception Handler (Java) | |||||||
Parasoft Jtest |
| CERT.ERR08.NCNPE | Do not catch 'NullPointerException' | ||||||
SonarQube |
| ||||||||
SpotBugs |
| DCN_NULLPOINTER_EXCEPTION | Implemented (since 4.5.0) |
...