You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-dev@hadoop.apache.org by "songwanging (JIRA)" <ji...@apache.org> on 2015/07/31 08:36:04 UTC

[jira] [Created] (HDFS-8841) Catch throwable return null

songwanging created HDFS-8841:
---------------------------------

             Summary: Catch throwable return null
                 Key: HDFS-8841
                 URL: https://issues.apache.org/jira/browse/HDFS-8841
             Project: Hadoop HDFS
          Issue Type: Bug
            Reporter: songwanging
            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)