[ 
https://issues.apache.org/jira/browse/LANG-967?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14231777#comment-14231777
 ] 

Sebb commented on LANG-967:
---------------------------

I think there are valid reasons for catching Throwable, logging it, and 
continuing (except as noted above).

For example, Tomcat needs to do this, so they have their own version:

https://svn.apache.org/repos/asf/tomcat/trunk/java/org/apache/jasper/util/ExceptionUtils.java

They used to have lots of instances where the code caught Throwable and logged 
it, but failed to propagate the ones that must not be ignored.

So long as the Javadoc makes clear that it is not for general use, I think it's 
safer than the alternative of failing to rethrow the really important ones.

> Code should never catch and ignore all Throwables
> -------------------------------------------------
>
>                 Key: LANG-967
>                 URL: https://issues.apache.org/jira/browse/LANG-967
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.exception.*
>            Reporter: Sebb
>             Fix For: Patch Needed
>
>
> Code should never catch and ignore all Throwables - ThreadDeath and 
> VirtualMachineError must be rethrown.
> It would be useful to provide a method to enforce this behaviour.
> For example,. as is done by the Tomcat method \[1] with source here \[2]
> Sample usage:
> {code}
> try {
>     reader.close();
> } catch (Throwable u) {
>     ExceptionUtils.handleThrowable(u);
> }
> {code}
> \[1] org.apache.tomcat.util.ExceptionUtils#handleThrowable()
> \[2] 
> https://svn.apache.org/repos/asf/tomcat/trunk/java/org/apache/tomcat/util/ExceptionUtils.java



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to