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

Sergey Ponomarev commented on LANG-967:
---------------------------------------

As it was mentioned you shouldn't catch Throwable until you understood what are 
you doing and even you you need then catch Error explicitly and even better to 
catch specific error.
For example if you received OutOfMemoryError then it can be so low memory that 
you even can't write to logs or wrap OOM into another exception. But you can 
try to recover an application by clearing some in-memory caches or temporary 
stop processing. See Apache Derby 
[LowMemory|http://people.apache.org/~kristwaa/jacoco/org.apache.derby.iapi.services.memory/LowMemory.java.html]
 class and it's usage as example of recovery.

The mentioned Tomcat's ExceptionUtils.handleThrowable() looks quite weird. It 
rethrowth VirtualMachineError and ThreadDeath while all others are silently 
eaten. Maybe Tomcat's developers know what they are doing but this is 
definitely very custom logic.
I think we have nothing to do here and the ticket can be closed

> 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
>            Priority: Major
>             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
(v7.6.3#76005)

Reply via email to