hadoop-hdfs-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "songwanging (JIRA)" <j...@apache.org>
Subject [jira] [Created] (HDFS-8842) Catch throwable
Date Fri, 31 Jul 2015 06:46:04 GMT
songwanging created HDFS-8842:

             Summary: Catch throwable 
                 Key: HDFS-8842
                 URL: https://issues.apache.org/jira/browse/HDFS-8842
             Project: Hadoop HDFS
          Issue Type: Bug
            Reporter: songwanging
            Priority: Critical

We came across a few instances where the code catches Throwable, but fails to rethrow anything.
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 Throwable to Exception.

For example:

In method tryGetPid(Process p) of class: hadoop-2.7.1-src\hadoop-common-project\hadoop-common\src\main\java\org\apache\hadoop\ha\ShellCommandFencer.java

private static String tryGetPid(Process p) {
    try {
    } catch (Throwable t) {
      LOG.trace("Unable to determine pid for " + p, t);
      return null;

In method uncaughtException(Thread t, Throwable e) of class: hadoop-2.7.1-src\hadoop-yarn-project\hadoop-yarn\hadoop-yarn-common\src\main\java\org\apache\hadoop\yarn\YarnUncaughtExceptionHandler.java

public void uncaughtException(Thread t, Throwable e) {
      try {
        LOG.fatal("Thread " + t + " threw an Error.  Shutting down now...", e);
      } catch (Throwable err) {
        //We don't want to not exit because of an issue with logging
        try {
          System.err.println("Halting due to Out Of Memory Error...");
        } catch (Throwable err) {
          //Again we done want to exit because of logging issues.

This message was sent by Atlassian JIRA

View raw message