diff options
author | cpovirk <cpovirk@google.com> | 2021-09-08 13:03:43 -0700 |
---|---|---|
committer | Google Java Core Libraries <java-core-libraries-team+copybara@google.com> | 2021-09-08 13:06:37 -0700 |
commit | f08dfc2a144fde71551fe028537459547c9eb746 (patch) | |
tree | e2c807372db4228b724e91ebb9c07128dd492164 | |
parent | d5c30e3f190f2c391559a2e37fbc8f407cdb5785 (diff) | |
download | guava-f08dfc2a144fde71551fe028537459547c9eb746.tar.gz |
Warn that `directExecutor` lets exceptions propagate without invoking an `UncaughtExceptionHandler`.
RELNOTES=n/a
PiperOrigin-RevId: 395541203
-rw-r--r-- | android/guava/src/com/google/common/util/concurrent/MoreExecutors.java | 6 | ||||
-rw-r--r-- | guava/src/com/google/common/util/concurrent/MoreExecutors.java | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/android/guava/src/com/google/common/util/concurrent/MoreExecutors.java b/android/guava/src/com/google/common/util/concurrent/MoreExecutors.java index 8437f3c50..eaf6501e9 100644 --- a/android/guava/src/com/google/common/util/concurrent/MoreExecutors.java +++ b/android/guava/src/com/google/common/util/concurrent/MoreExecutors.java @@ -394,6 +394,12 @@ public final class MoreExecutors { * (In simple cases, callers can avoid this by registering all tasks with the same {@link * MoreExecutors#newSequentialExecutor} wrapper around {@code directExecutor()}. More * complex cases may require using thread pools or making deeper changes.) + * <li>If an exception propagates out of a {@code Runnable}, it is not necessarily seen by any + * {@code UncaughtExceptionHandler} for the thread. For example, if the callback passed to + * {@link Futures#addCallback} throws an exception, that exception will be typically be + * logged by the {@link ListenableFuture} implementation, even if the thread is configured + * to do something different. In other cases, no code will catch the exception, and it may + * terminate whichever thread happens to trigger the execution. * </ul> * * Additionally, beware of executing tasks with {@code directExecutor} while holding a lock. Since diff --git a/guava/src/com/google/common/util/concurrent/MoreExecutors.java b/guava/src/com/google/common/util/concurrent/MoreExecutors.java index 4b8a2e85d..fc61fbab3 100644 --- a/guava/src/com/google/common/util/concurrent/MoreExecutors.java +++ b/guava/src/com/google/common/util/concurrent/MoreExecutors.java @@ -455,6 +455,12 @@ public final class MoreExecutors { * (In simple cases, callers can avoid this by registering all tasks with the same {@link * MoreExecutors#newSequentialExecutor} wrapper around {@code directExecutor()}. More * complex cases may require using thread pools or making deeper changes.) + * <li>If an exception propagates out of a {@code Runnable}, it is not necessarily seen by any + * {@code UncaughtExceptionHandler} for the thread. For example, if the callback passed to + * {@link Futures#addCallback} throws an exception, that exception will be typically be + * logged by the {@link ListenableFuture} implementation, even if the thread is configured + * to do something different. In other cases, no code will catch the exception, and it may + * terminate whichever thread happens to trigger the execution. * </ul> * * Additionally, beware of executing tasks with {@code directExecutor} while holding a lock. Since |