HADOOP-8801. ExitUtil#terminate should capture the exception stack trace. Contributed by Eli Collins

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1384435 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Eli Collins 2012-09-13 17:56:49 +00:00
parent d543140089
commit eb7f8a71e0
2 changed files with 9 additions and 1 deletions

View File

@ -355,6 +355,8 @@ Release 2.0.2-alpha - 2012-09-07
HADOOP-8754. Deprecate all the RPC.getServer() variants. (Brandon Li HADOOP-8754. Deprecate all the RPC.getServer() variants. (Brandon Li
via szetszwo) via szetszwo)
HADOOP-8801. ExitUtil#terminate should capture the exception stack trace. (eli)
BUG FIXES BUG FIXES
HADOOP-8372. NetUtils.normalizeHostName() incorrectly handles hostname HADOOP-8372. NetUtils.normalizeHostName() incorrectly handles hostname

View File

@ -17,6 +17,9 @@
*/ */
package org.apache.hadoop.util; package org.apache.hadoop.util;
import java.io.PrintWriter;
import java.io.StringWriter;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceAudience;
@ -101,7 +104,10 @@ public final class ExitUtil {
* @throws ExitException if System.exit is disabled for test purposes * @throws ExitException if System.exit is disabled for test purposes
*/ */
public static void terminate(int status, Throwable t) throws ExitException { public static void terminate(int status, Throwable t) throws ExitException {
terminate(status, t.getMessage()); StringWriter sw = new StringWriter();
t.printStackTrace(new PrintWriter(sw));
terminate(status, "Fatal exception with message " + t.getMessage() +
"\nstack trace\n" + sw.toString());
} }
/** /**