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
diff --git a/test/008-exceptions/src/Main.java b/test/008-exceptions/src/Main.java
index 9e3477a..b8231f1 100644
--- a/test/008-exceptions/src/Main.java
+++ b/test/008-exceptions/src/Main.java
@@ -60,7 +60,7 @@
} 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 @@
System.out.println(e.getCause());
}
} catch (Exception error) {
- error.printStackTrace();
+ error.printStackTrace(System.out);
}
}
@@ -126,7 +126,7 @@
System.out.println(e.getCause());
}
} catch (Exception error) {
- error.printStackTrace();
+ error.printStackTrace(System.out);
}
}
}