Browse Source

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.0.2-alpha@1384439 13f79535-47bb-0310-9956-ffa450edef68
Eli Collins 12 năm trước cách đây
mục cha
commit
ccd6e9200a

+ 2 - 0
hadoop-common-project/hadoop-common/CHANGES.txt

@@ -113,6 +113,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

+ 7 - 1
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());
   }
 
   /**