From a7f6b089d71b853728e0885334f6dafd2e51be25 Mon Sep 17 00:00:00 2001 From: cpovirk Date: Sat, 5 Mar 2022 05:55:39 -0800 Subject: [PATCH] Remove `@CanIgnoreReturnValue` from `Futures.combine` and from all `FutureCombiner` methods. PiperOrigin-RevId: 432643990 --- .../common/util/concurrent/Futures.java | 19 +++++++++++++++++-- .../common/util/concurrent/Futures.java | 19 +++++++++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/android/guava/src/com/google/common/util/concurrent/Futures.java b/android/guava/src/com/google/common/util/concurrent/Futures.java index 6bd68b4b5c5a..660c04d3249d 100644 --- a/android/guava/src/com/google/common/util/concurrent/Futures.java +++ b/android/guava/src/com/google/common/util/concurrent/Futures.java @@ -661,7 +661,6 @@ private O applyTransformation(I input) throws ExecutionException { * @since 20.0 */ @Beta - @CanIgnoreReturnValue // TODO(cpovirk): Consider removing, especially if we provide run(Runnable) @GwtCompatible public static final class FutureCombiner { private final boolean allMustSucceed; @@ -686,6 +685,12 @@ private FutureCombiner( * ExecutionException} that gets thrown by the returned combined future. * *

Canceling this future will attempt to cancel all the component futures. + * + * @return a future whose result is based on {@code combiner} (or based on the input futures + * passed to {@code whenAllSucceed}, if that is the method you used to create this {@code + * FutureCombiner}). Even if you don't care about the value of the future, you should + * typically check whether it failed: See https://errorprone.info/bugpattern/FutureReturnValueIgnored. */ public ListenableFuture callAsync( AsyncCallable combiner, Executor executor) { @@ -705,8 +710,13 @@ private FutureCombiner( * ExecutionException} that gets thrown by the returned combined future. * *

Canceling this future will attempt to cancel all the component futures. + * + * @return a future whose result is based on {@code combiner} (or based on the input futures + * passed to {@code whenAllSucceed}, if that is the method you used to create this {@code + * FutureCombiner}). Even if you don't care about the value of the future, you should + * typically check whether it failed: See https://errorprone.info/bugpattern/FutureReturnValueIgnored. */ - @CanIgnoreReturnValue // TODO(cpovirk): Remove this public ListenableFuture call( Callable combiner, Executor executor) { return new CombinedFuture(futures, allMustSucceed, executor, combiner); @@ -722,6 +732,11 @@ private FutureCombiner( *

Canceling this Future will attempt to cancel all the component futures. * * @since 23.6 + * @return a future whose result is based on {@code combiner} (or based on the input futures + * passed to {@code whenAllSucceed}, if that is the method you used to create this {@code + * FutureCombiner}). Even though the future never produces a value other than {@code null}, + * you should typically check whether it failed: See https://errorprone.info/bugpattern/FutureReturnValueIgnored. */ public ListenableFuture run(final Runnable combiner, Executor executor) { return call( diff --git a/guava/src/com/google/common/util/concurrent/Futures.java b/guava/src/com/google/common/util/concurrent/Futures.java index 09b5c3c1a426..466f309c65c0 100644 --- a/guava/src/com/google/common/util/concurrent/Futures.java +++ b/guava/src/com/google/common/util/concurrent/Futures.java @@ -694,7 +694,6 @@ private O applyTransformation(I input) throws ExecutionException { * @since 20.0 */ @Beta - @CanIgnoreReturnValue // TODO(cpovirk): Consider removing, especially if we provide run(Runnable) @GwtCompatible public static final class FutureCombiner { private final boolean allMustSucceed; @@ -719,6 +718,12 @@ private FutureCombiner( * ExecutionException} that gets thrown by the returned combined future. * *

Canceling this future will attempt to cancel all the component futures. + * + * @return a future whose result is based on {@code combiner} (or based on the input futures + * passed to {@code whenAllSucceed}, if that is the method you used to create this {@code + * FutureCombiner}). Even if you don't care about the value of the future, you should + * typically check whether it failed: See https://errorprone.info/bugpattern/FutureReturnValueIgnored. */ public ListenableFuture callAsync( AsyncCallable combiner, Executor executor) { @@ -738,8 +743,13 @@ private FutureCombiner( * ExecutionException} that gets thrown by the returned combined future. * *

Canceling this future will attempt to cancel all the component futures. + * + * @return a future whose result is based on {@code combiner} (or based on the input futures + * passed to {@code whenAllSucceed}, if that is the method you used to create this {@code + * FutureCombiner}). Even if you don't care about the value of the future, you should + * typically check whether it failed: See https://errorprone.info/bugpattern/FutureReturnValueIgnored. */ - @CanIgnoreReturnValue // TODO(cpovirk): Remove this public ListenableFuture call( Callable combiner, Executor executor) { return new CombinedFuture(futures, allMustSucceed, executor, combiner); @@ -755,6 +765,11 @@ private FutureCombiner( *

Canceling this Future will attempt to cancel all the component futures. * * @since 23.6 + * @return a future whose result is based on {@code combiner} (or based on the input futures + * passed to {@code whenAllSucceed}, if that is the method you used to create this {@code + * FutureCombiner}). Even though the future never produces a value other than {@code null}, + * you should typically check whether it failed: See https://errorprone.info/bugpattern/FutureReturnValueIgnored. */ public ListenableFuture run(final Runnable combiner, Executor executor) { return call(