Class CompletionExceptionLogHelper

    • Method Detail

      • setAddSuppressed

        public static void setAddSuppressed​(boolean addSuppressed)
        Change whether Throwable.addSuppressed(java.lang.Throwable) is used. When enabled, the exception graph will have a circularity. This can cause problems for some logging frameworks and so may need to be disabled if using one of them.
        Parameters:
        addSuppressed - true to use addSuppressed to give more information in logs
      • setMaxSuppressedCountIfNotSet

        public static boolean setMaxSuppressedCountIfNotSet​(int count)
        Change the maximum number of suppressed exceptions to add to any given exception, if this maximum has not already been set. Return whether or not the maximum was changed. This method only changes behavior when addSuppressed is true.
        Parameters:
        count - the new maximum count
        Returns:
        true if the count was changed and false if it was not
      • forceSetMaxSuppressedCountForTesting

        @API(INTERNAL)
        public static void forceSetMaxSuppressedCountForTesting​(int count)
        Change the maximum number of suppressed exceptions to add to any given exception, even if the maximum has already been set. This should be done with extreme care: asCauseThrowable(Throwable) may misbehave if it handles exceptions before and after this method is called with the same cause. It should ONLY be used for testing without restarting the JVM.
        Parameters:
        count - the new maximum count
      • asCause

        public static Throwable asCause​(@Nonnull
                                        CompletionException ex)
        Return the cause of the given exception and also arrange for the original exception to be in the suppressed chain.
        Parameters:
        ex - an exception from CompletableFuture.join() or the like
        Returns:
        a throwable suitable for use as the cause of a wrapped exception
      • asCause

        public static Throwable asCause​(@Nonnull
                                        ExecutionException ex)
        Return the cause of the given exception and also arrange for the original exception to be in the suppressed chain. However, if the given exception's cause already has the maximum number of suppressed exceptions specified by setMaxSuppressedCountIfNotSet(int), then the given exception is not added to the suppressed chain and the exception counting the number of ignored exceptions is incremented instead.
        Parameters:
        ex - an exception from CompletableFuture.get() or the like
        Returns:
        a throwable suitable for use as the cause of a wrapped exception