From 64daeddb621ec4879d6a723a4748dd8b11023607 Mon Sep 17 00:00:00 2001 From: Kevin Brodsky Date: Mon, 14 Dec 2015 10:15:04 +0000 Subject: Make the 008-exceptions test print everything to stdout Printing to different streams (stderr and stdout) may cause the messages to be interleaved, making the test fail. Without this patch, this kind of outcome has been observed: --- expected.txt 2015-12-09 08:13:50.583294910 +0000 +++ output.txt 2015-12-09 08:55:35.635185771 +0000 @@ -1,15 +1,15 @@ Got an NPE: second throw java.lang.NullPointerException: second throw - at Main.catchAndRethrow(Main.java:77) +Static Init +BadError: This is bad by convention: BadInit +java.lang.NoClassDefFoundError: BadInit at Main.catchAndRethrow(Main.java:77) at Main.exceptions_007(Main.java:59) at Main.main(Main.java:67) Caused by: java.lang.NullPointerException: first throw at Main.throwNullPointerException(Main.java:84) at Main.catchAndRethrow(Main.java:74) ... 2 more -Static Init -BadError: This is bad by convention: BadInit -java.lang.NoClassDefFoundError: BadInit + BadError: This is bad by convention: BadInit Static BadInitNoStringInit BadErrorNoStringInit: This is bad by convention Change-Id: Iaabf5ed593d100abf157adf46c1761338227d2cf --- test/008-exceptions/src/Main.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/008-exceptions/src') diff --git a/test/008-exceptions/src/Main.java b/test/008-exceptions/src/Main.java index 9e3477a47b..b8231f12bd 100644 --- a/test/008-exceptions/src/Main.java +++ b/test/008-exceptions/src/Main.java @@ -60,7 +60,7 @@ public class Main { } catch (NullPointerException npe) { System.out.print("Got an NPE: "); System.out.println(npe.getMessage()); - npe.printStackTrace(); + npe.printStackTrace(System.out); } } public static void main (String args[]) { @@ -103,7 +103,7 @@ public class Main { System.out.println(e.getCause()); } } catch (Exception error) { - error.printStackTrace(); + error.printStackTrace(System.out); } } @@ -126,7 +126,7 @@ public class Main { System.out.println(e.getCause()); } } catch (Exception error) { - error.printStackTrace(); + error.printStackTrace(System.out); } } } -- cgit v1.2.3-59-g8ed1b