Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Methods must not throw RuntimeException or Exception. Handling these exceptions requires catching RuntimeException, which is disallowed by rule ERR14-J. Do not catch NullPointerException , RuntimeException, Exception, or Throwableor any of its ancestors. Moreover, throwing a RuntimeException can lead to subtle errors, for example, a caller cannot examine the exception to determine why it was thrown, and consequently cannot attempt recovery.

...

A calling method must also violate rule ERR14-J. Do not catch NullPointerException , RuntimeException, Exception, or Throwableor any of its ancestors to determine if the https://www.securecoding.cert.org/confluence/pages/editpage.action?pageId=24608774RuntimeException was thrown.

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="0553246fbc1cd92e-ad93040d-461f4fb1-85a6a926-359c7666b02204044b3cad7a"><ac:plain-text-body><![CDATA[

[[MITRE 2009

AA. Bibliography#MITRE 09]]

[CWE ID 397

http://cwe.mitre.org/data/definitions/397.html] "Declaration of Throws for Generic Exception"

]]></ac:plain-text-body></ac:structured-macro>

 

CWE ID 537 "Information Exposure Through Java Runtime Error Message"

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="212d09f8f8ce3242-9a3e941b-4deb47a7-bb7d90e6-7e864ed256b44e5404c24f3e"><ac:plain-text-body><![CDATA[

[[Goetz 2004b

AA. Bibliography#Goetz 04b]]

 

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="e61ffc63c3e25e1e-2a64d454-4b71445a-87a78f39-4595666939ca0a425019b6db"><ac:plain-text-body><![CDATA[

[[Tutorials 2008

AA. Bibliography#Tutorials 08]]

[Unchecked Exceptions — The Controversy

http://java.sun.com/docs/books/tutorial/essential/exceptions/runtime.html]

]]></ac:plain-text-body></ac:structured-macro>

...

ERR11-J. Restore prior object state on method failure      06. Exceptional Behavior (ERR)      ERR14-J. Do not catch NullPointerException , RuntimeException, Exception, or Throwableor any of its ancestors