Catch NullPointerException

Last revision (mm/dd/yy): //

Vulnerabilities Table of Contents

Description
It is generally a bad practice to catch NullPointerException.

Programmers typically catch NullPointerException under three circumstances:

Of these three circumstances, only the last is acceptable.
 * 1) The program contains a null pointer dereference. Catching the resulting exception was easier than fixing the underlying problem.
 * 2) The program explicitly throws a NullPointerException to signal an error condition.
 * 3) The code is part of a test harness that supplies unexpected input to the classes under test.

Risk Factors
TBD

Examples
The following code mistakenly catches a NullPointerException.

try { mysteryMethod; }	 catch (NullPointerException npe) { }

Related Attacks

 * Attack 1
 * Attack 2

Related Vulnerabilities

 * Vulnerability 1
 * Vulnerabiltiy 2

Related Controls

 * Category:Error Handling

Related Technical Impacts

 * Technical Impact 1
 * Technical Impact 2