commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LANG-967) Code should never catch and ignore all Throwables
Date Tue, 25 Mar 2014 22:01:20 GMT

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

Niall Pemberton commented on LANG-967:
--------------------------------------

This seems like a bad idea to me - what circumstances is it good to catch/ignore any Errors?
We shouldn't encourage use of this by providing a dangerous method IMO. Especially since its
a potential bomb for any new Errors that may be added in the future.

{code}
try {
    reader.close();
} catch (Exception e) {
}
{code}

> 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
>            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.2#6252)

Mime
View raw message