...
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 | Detectable | RepairableRemediation Cost | Priority | Level |
|---|---|---|---|---|---|---|
ERR08-J | Medium | Likely | Yes | NoMedium | P12 | L1 |
Automated Detection
| Tool | Version | Checker | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
| CodeSonar |
| JAVA.STRUCT.EXCP.GEH | Generic exception handler | ||||||
| Klocwork |
| JD.CATCH | |||||||
| Parasoft Jtest |
| CERT.ERR08.NCNPE | Do not catch 'NullPointerException' | ||||||
| SonarQube |
| ||||||||
| SpotBugs |
| DCN_NULLPOINTER_EXCEPTION | Implemented (since 4.5.0) |
...