Details
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
catch (Throwable err)
{ //We don't want to not exit because of an issue with logging } ...
try
catch (Throwable err)
{ //Again we done want to exit because of logging issues. } ...
}