6
I’ve been a little uneasy about security issues and vulnerabilities lately, and in my research, I came up with an article that intrigued me.
According to the OWASP:
Description It is generally a bad Practice to catch Nullpointerexception.
Programmers typically catch Nullpointerexception under three Circumstances:
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. Of These three Circumstances, only the last is acceptable.
That is, according to this text, the only acceptable situation to catch NullPointerException
is in test cases, where the input can be something unexpected.
Why is it not a good idea to capture NullPointerException
?
Since this is not a good idea, how should I proceed if this exception is something plausible within a scope?
Like NullPointerException
may be a threat to my system?
Bad practice regarding something specific?
– Jéf Bueno
Apparently, OWASP considers the capture of
NullPointerException
bad security practice. It even says it’s a mistake to capture such an exception– Artur Trapp
Related: Best practices with Java exception handling
– user28595
I should put that in the title?
– Artur Trapp
The first two questions are answered in @bigown’s reply at this link.
– user28595
Really enlightening his reply, thank you very much
– Artur Trapp