ctubbsii commented on code in PR #5574: URL: https://github.com/apache/accumulo/pull/5574#discussion_r2112516143
########## core/src/main/java/org/apache/accumulo/core/util/Halt.java: ########## @@ -28,34 +28,43 @@ public class Halt { private static final Logger log = LoggerFactory.getLogger(Halt.class); - public static void halt(final String msg) { - // ACCUMULO-3651 Changed level to error and added FATAL to message for slf4j compatibility - halt(0, new Runnable() { - @Override - public void run() { - log.error("FATAL {}", msg); - } - }); + public static void halt(final int status, final String msg) { + halt(status, msg, null, null); } - public static void halt(final String msg, int status) { - halt(status, new Runnable() { - @Override - public void run() { - log.error("FATAL {}", msg); - } - }); + public static void halt(final int status, final String msg, final Throwable exception) { + halt(status, msg, exception, null); } - public static void halt(final int status, Runnable runnable) { + public static void halt(final int status, final String msg, final Runnable runnable) { + halt(status, msg, null, runnable); + } + public static void halt(final int status, final String msg, final Throwable exception, + final Runnable runnable) { try { + // give ourselves a little time to try and do something Threads.createThread("Halt Thread", () -> { sleepUninterruptibly(100, MILLISECONDS); Runtime.getRuntime().halt(status); }).start(); + final String errorMessage = "FATAL " + msg; + // Printing to stderr and to the log in case the message does not make + // it to the log. This could happen if an asynchronous logging impl is used + System.err.println(errorMessage); + if (exception != null) { + exception.printStackTrace(); + } + System.err.flush(); + + if (exception != null) { + log.error(errorMessage, exception); + } else { + log.error(errorMessage); Review Comment: The first parameter for the `log.error()` function is a format string, not a fixed string. So, this could result in errors. It should instead be: ```suggestion log.error("{}", errorMessage, exception); } else { log.error("{}", errorMessage); ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@accumulo.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org