This site is the archived OWASP Foundation Wiki and is no longer accepting Account Requests.
To view the new OWASP Foundation website, please visit https://owasp.org
Difference between revisions of "Catch NullPointerException"
From OWASP
Line 1: | Line 1: | ||
{{Template:Vulnerability}} | {{Template:Vulnerability}} | ||
{{Template:Fortify}} | {{Template:Fortify}} | ||
− | |||
− | |||
− | |||
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}''' | Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}''' | ||
− | + | [[ASDR_TOC_Vulnerabilities|Vulnerabilities Table of Contents]] | |
− | [[ | ||
− | |||
==Description== | ==Description== |
Revision as of 00:17, 21 February 2009
This is a Vulnerability. To view all vulnerabilities, please see the Vulnerability Category page.
Last revision (mm/dd/yy): 02/21/2009
Vulnerabilities Table of Contents
Description
It is generally a bad practice to catch NullPointerException.
Programmers typically catch NullPointerException under three circumstances:
- The program contains a null pointer dereference. Catching the resulting exception was easier than fixing the underlying problem.
- The program explicitly throws a NullPointerException to signal an error condition.
- The code is part of a test harness that supplies unexpected input to the classes under test.
Of these three circumstances, only the last is acceptable.
Risk Factors
TBD
Examples
The following code mistakenly catches a NullPointerException.
try { mysteryMethod(); } catch (NullPointerException npe) { }
Related Attacks
Related Vulnerabilities
Related Controls
Related Technical Impacts
References
Note: A reference to related CWE or CAPEC article should be added when exists. Eg: