From 9bfa8fd5296937346441bd07be531df4494b6d33 Mon Sep 17 00:00:00 2001 From: Eli Collins Date: Thu, 13 Sep 2012 17:58:28 +0000 Subject: [PATCH] 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/branches/branch-2@1384438 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-common-project/hadoop-common/CHANGES.txt | 2 ++ .../src/main/java/org/apache/hadoop/util/ExitUtil.java | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 1beea0ff4f4..ac3439c9a06 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -134,6 +134,8 @@ Release 2.0.2-alpha - 2012-09-07 HADOOP-8754. Deprecate all the RPC.getServer() variants. (Brandon Li via szetszwo) + HADOOP-8801. ExitUtil#terminate should capture the exception stack trace. (eli) + BUG FIXES HADOOP-8372. NetUtils.normalizeHostName() incorrectly handles hostname diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ExitUtil.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ExitUtil.java index aad7ca03be9..54a96bbe00a 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ExitUtil.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ExitUtil.java @@ -17,6 +17,9 @@ */ package org.apache.hadoop.util; +import java.io.PrintWriter; +import java.io.StringWriter; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.classification.InterfaceAudience; @@ -101,7 +104,10 @@ public final class ExitUtil { * @throws ExitException if System.exit is disabled for test purposes */ 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()); } /**