HADOOP-8812. ExitUtil#terminate should print Exception#toString. Contributed by Eli Collins

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1387275 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Eli Collins 2012-09-18 17:34:32 +00:00
parent d1e2d368a4
commit 6ad11b963c
3 changed files with 5 additions and 13 deletions

View File

@ -232,6 +232,8 @@ Release 2.0.3-alpha - Unreleased
HADOOP-8806. libhadoop.so: dlopen should be better at locating HADOOP-8806. libhadoop.so: dlopen should be better at locating
libsnappy.so, etc. (Colin Patrick McCabe via eli) libsnappy.so, etc. (Colin Patrick McCabe via eli)
HADOOP-8812. ExitUtil#terminate should print Exception#toString. (eli)
OPTIMIZATIONS OPTIMIZATIONS
BUG FIXES BUG FIXES

View File

@ -17,9 +17,6 @@
*/ */
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;
@ -104,10 +101,7 @@ 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 {
StringWriter sw = new StringWriter(); terminate(status, StringUtils.stringifyException(t));
t.printStackTrace(new PrintWriter(sw));
terminate(status, "Fatal exception with message " + t.getMessage() +
"\nstack trace\n" + sw.toString());
} }
/** /**

View File

@ -31,9 +31,7 @@ import java.io.File;
import java.io.FilenameFilter; import java.io.FilenameFilter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.PrintWriter;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
import java.io.StringWriter;
import java.net.URI; import java.net.URI;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -1229,10 +1227,8 @@ public class TestEditLog {
} }
} catch (IOException e) { } catch (IOException e) {
} catch (Throwable t) { } catch (Throwable t) {
StringWriter sw = new StringWriter(); fail("Caught non-IOException throwable " +
t.printStackTrace(new PrintWriter(sw)); StringUtils.stringifyException(t));
fail("caught non-IOException throwable with message " +
t.getMessage() + "\nstack trace\n" + sw.toString());
} }
} finally { } finally {
if ((elfos != null) && (elfos.isOpen())) if ((elfos != null) && (elfos.isOpen()))