hadoop-hdfs-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jagadesh Kiran N (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HDFS-8841) Catch throwable return null
Date Mon, 03 Aug 2015 10:01:04 GMT

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

Jagadesh Kiran N commented on HDFS-8841:
----------------------------------------

I failed to see the chance of Error(like ClassNotFoundError) in the following code. Could
you please point me to the same. Thanks!

try {
final Path tmp = new Path(job.get(TMP_DIR_LABEL), relativedst);
if (destFileSys.delete(tmp, true))
break;
} catch (Throwable ex) {
// ignore, we are just cleaning up
LOG.debug("Ignoring cleanup exception", ex);
}

> Catch throwable return null
> ---------------------------
>
>                 Key: HDFS-8841
>                 URL: https://issues.apache.org/jira/browse/HDFS-8841
>             Project: Hadoop HDFS
>          Issue Type: Bug
>            Reporter: songwanging
>            Assignee: Jagadesh Kiran N
>            Priority: Minor
>
> In method "map" of class: \hadoop-2.7.1-src\hadoop-tools\hadoop-extras\src\main\java\org\apache\hadoop\tools\DistCpV1.java.
> This method has this code:
>  public void map(LongWritable key,
>                     FilePair value,
>                     OutputCollector<WritableComparable<?>, Text> out,
>                     Reporter reporter) throws IOException {
>          ...
>             } catch (Throwable ex) {
>               // ignore, we are just cleaning up
>               LOG.debug("Ignoring cleanup exception", ex);
>             }
>            ....
>           }
>         } 
>         ...
>     }
> Throwable is the parent type of Exception and Error, so catching Throwable means catching
both Exceptions as well as Errors. An Exception is something you could recover (like IOException),
an Error is something more serious and usually you could'nt recover easily (like ClassNotFoundError)
so it doesn't make much sense to catch an Error.
> We should  convert to catch Exception instead.



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

Mime
View raw message