@API(value=MAINTAINED) public class CompletionExceptionLogHelper extends Object
CompletionException
s.
The CompletionException
has a stack trace that indicates the call to a wait point, such as
FDBRecordContext.asyncToSync(com.apple.foundationdb.record.provider.common.StoreTimer.Wait, java.util.concurrent.CompletableFuture<T>)
, which may
be the only indication of what the caller was actually doing.
But the cause of this exception is the one to analyze and wrap
in an appropriate subclass of RecordCoreException
, so that
is returned, after remembering the original exception as a suppressed exception.Modifier and Type | Class and Description |
---|---|
static class |
CompletionExceptionLogHelper.IgnoredSuppressedExceptionCount
A special "exception" to record the number of suppressed exceptions that were not recorded due to the
maxSuppressedCount . |
Modifier and Type | Method and Description |
---|---|
static Throwable |
asCause(CompletionException ex)
Return the cause of the given exception and also arrange for the original exception to be in the suppressed chain.
|
static Throwable |
asCause(ExecutionException ex)
Return the cause of the given exception and also arrange for the original exception to be in the suppressed chain.
|
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.
|
static void |
setAddSuppressed(boolean addSuppressed)
Change whether
Throwable.addSuppressed(java.lang.Throwable) is used. |
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.
|
public static void setAddSuppressed(boolean addSuppressed)
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.addSuppressed
- true
to use addSuppressed
to give more information in logspublic static boolean setMaxSuppressedCountIfNotSet(int count)
addSuppressed
is true
.count
- the new maximum counttrue
if the count was changed and false
if it was not@API(value=INTERNAL) public static void forceSetMaxSuppressedCountForTesting(int count)
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.count
- the new maximum countpublic static Throwable asCause(@Nonnull CompletionException ex)
ex
- an exception from CompletableFuture.join()
or the likepublic static Throwable asCause(@Nonnull ExecutionException ex)
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.ex
- an exception from CompletableFuture.get()
or the like