From 2714bb2fefb878f53ff74d6b50dff5f4c5373a6a Mon Sep 17 00:00:00 2001 From: Dmitry Vyazelenko <696855+vyazelenko@users.noreply.github.com> Date: Tue, 10 Dec 2019 23:44:31 +0100 Subject: [PATCH] [Java] Print stacktrace to `System.err` and ensure the same `PrintStream` instance is used --- aeron-client/src/main/java/io/aeron/Aeron.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/aeron-client/src/main/java/io/aeron/Aeron.java b/aeron-client/src/main/java/io/aeron/Aeron.java index 0cfefdbc21..7e58c7f06a 100644 --- a/aeron-client/src/main/java/io/aeron/Aeron.java +++ b/aeron-client/src/main/java/io/aeron/Aeron.java @@ -521,14 +521,15 @@ public static class Configuration public static final ErrorHandler DEFAULT_ERROR_HANDLER = (throwable) -> { - synchronized (System.err) + final PrintStream err = System.err; + synchronized (err) { - System.err.println(System.currentTimeMillis() + " Exception:"); - throwable.printStackTrace(); + err.println(System.currentTimeMillis() + " Exception:"); + throwable.printStackTrace(err); } if (throwable instanceof DriverTimeoutException) { - System.err.printf( + err.printf( "%n***%n*** timeout for the Media Driver - is it currently running? exiting%n***%n"); System.exit(-1); }