Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-8842

Catch throwable

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Trivial
    • Resolution: Unresolved
    • None
    • None
    • None
    • None

    Description

      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

      code:
      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

      code:
      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. }

      ...
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            songwang songwanging
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: