/** * @return a list of describing each permit that wasn't released yet. The description consist of the debugInfo supplied * when the permit was acquired plus a stack traces that was captured when the permit was request. */ List<String> getActiveOperations() { return issuedPermits.values().stream().map( t -> t.v1() + "\n" + ExceptionsHelper.formatStackTrace(t.v2())) .collect(Collectors.toList()); }
/** * If the specified cause is an unrecoverable error, this method will rethrow the cause on a separate thread so that it can not be * caught and bubbles up to the uncaught exception handler. Note that the cause tree is examined for any {@link Error}. See * {@link #maybeError(Throwable, Logger)} for the semantics. * * @param throwable the throwable to possibly throw on another thread */ public static void maybeDieOnAnotherThread(final Throwable throwable) { ExceptionsHelper.maybeError(throwable, logger).ifPresent(error -> { /* * Here be dragons. We want to rethrow this so that it bubbles up to the uncaught exception handler. Yet, sometimes the stack * contains statements that catch any throwable (e.g., Netty, and the JDK futures framework). This means that a rethrow here * will not bubble up to where we want it to. So, we fork a thread and throw the exception from there where we are sure the * stack does not contain statements that catch any throwable. We do not wrap the exception so as to not lose the original cause * during exit. */ try { // try to log the current stack trace final String formatted = ExceptionsHelper.formatStackTrace(Thread.currentThread().getStackTrace()); logger.error("fatal error\n{}", formatted); } finally { new Thread( () -> { throw error; }) .start(); } }); }
/** * @return a list of describing each permit that wasn't released yet. The description consist of the debugInfo supplied * when the permit was acquired plus a stack traces that was captured when the permit was request. */ List<String> getActiveOperations() { return issuedPermits.values().stream().map( t -> t.v1() + "\n" + ExceptionsHelper.formatStackTrace(t.v2())) .collect(Collectors.toList()); }
/** * @return a list of describing each permit that wasn't released yet. The description consist of the debugInfo supplied * when the permit was acquired plus a stack traces that was captured when the permit was request. */ List<String> getActiveOperations() { return issuedPermits.values().stream().map( t -> t.v1() + "\n" + ExceptionsHelper.formatStackTrace(t.v2())) .collect(Collectors.toList()); }
/** * If the specified cause is an unrecoverable error, this method will rethrow the cause on a separate thread so that it can not be * caught and bubbles up to the uncaught exception handler. Note that the cause tree is examined for any {@link Error}. See * {@link #maybeError(Throwable, Logger)} for the semantics. * * @param throwable the throwable to possibly throw on another thread */ public static void maybeDieOnAnotherThread(final Throwable throwable) { ExceptionsHelper.maybeError(throwable, logger).ifPresent(error -> { /* * Here be dragons. We want to rethrow this so that it bubbles up to the uncaught exception handler. Yet, sometimes the stack * contains statements that catch any throwable (e.g., Netty, and the JDK futures framework). This means that a rethrow here * will not bubble up to where we want it to. So, we fork a thread and throw the exception from there where we are sure the * stack does not contain statements that catch any throwable. We do not wrap the exception so as to not lose the original cause * during exit. */ try { // try to log the current stack trace final String formatted = ExceptionsHelper.formatStackTrace(Thread.currentThread().getStackTrace()); logger.error("fatal error\n{}", formatted); } finally { new Thread( () -> { throw error; }) .start(); } }); }
final String formatted = ExceptionsHelper.formatStackTrace(Thread.currentThread().getStackTrace()); logger.error("fatal error\n{}", formatted); } finally {