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="243f803420e5521d-4670f6fe-49c94d9d-90458851-67b868887f3585a3fb1ecf6a"><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="50e9919eb93e826e-41652ac3-4452423d-bebfb0f6-671342450affc689dc1adeb2"><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="726cdc765db8b1bf-2d7a7a82-4f7c4607-b5bbafa6-7bade43e67738888f76edafc"><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