Skip to content

Commit

Permalink
Remove @CanIgnoreReturnValue from Futures.combine and from all `F…
Browse files Browse the repository at this point in the history
…utureCombiner` methods.

PiperOrigin-RevId: 432643990
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Mar 5, 2022
1 parent 24c1b85 commit a7f6b08
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
19 changes: 17 additions & 2 deletions android/guava/src/com/google/common/util/concurrent/Futures.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<V extends @Nullable Object> {
private final boolean allMustSucceed;
Expand All @@ -686,6 +685,12 @@ private FutureCombiner(
* ExecutionException} that gets thrown by the returned combined future.
*
* <p>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 <a
* href="https://errorprone.info/bugpattern/FutureReturnValueIgnored">https://errorprone.info/bugpattern/FutureReturnValueIgnored</a>.
*/
public <C extends @Nullable Object> ListenableFuture<C> callAsync(
AsyncCallable<C> combiner, Executor executor) {
Expand All @@ -705,8 +710,13 @@ private FutureCombiner(
* ExecutionException} that gets thrown by the returned combined future.
*
* <p>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 <a
* href="https://errorprone.info/bugpattern/FutureReturnValueIgnored">https://errorprone.info/bugpattern/FutureReturnValueIgnored</a>.
*/
@CanIgnoreReturnValue // TODO(cpovirk): Remove this
public <C extends @Nullable Object> ListenableFuture<C> call(
Callable<C> combiner, Executor executor) {
return new CombinedFuture<C>(futures, allMustSucceed, executor, combiner);
Expand All @@ -722,6 +732,11 @@ private FutureCombiner(
* <p>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 <a
* href="https://errorprone.info/bugpattern/FutureReturnValueIgnored">https://errorprone.info/bugpattern/FutureReturnValueIgnored</a>.
*/
public ListenableFuture<?> run(final Runnable combiner, Executor executor) {
return call(
Expand Down
19 changes: 17 additions & 2 deletions guava/src/com/google/common/util/concurrent/Futures.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<V extends @Nullable Object> {
private final boolean allMustSucceed;
Expand All @@ -719,6 +718,12 @@ private FutureCombiner(
* ExecutionException} that gets thrown by the returned combined future.
*
* <p>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 <a
* href="https://errorprone.info/bugpattern/FutureReturnValueIgnored">https://errorprone.info/bugpattern/FutureReturnValueIgnored</a>.
*/
public <C extends @Nullable Object> ListenableFuture<C> callAsync(
AsyncCallable<C> combiner, Executor executor) {
Expand All @@ -738,8 +743,13 @@ private FutureCombiner(
* ExecutionException} that gets thrown by the returned combined future.
*
* <p>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 <a
* href="https://errorprone.info/bugpattern/FutureReturnValueIgnored">https://errorprone.info/bugpattern/FutureReturnValueIgnored</a>.
*/
@CanIgnoreReturnValue // TODO(cpovirk): Remove this
public <C extends @Nullable Object> ListenableFuture<C> call(
Callable<C> combiner, Executor executor) {
return new CombinedFuture<C>(futures, allMustSucceed, executor, combiner);
Expand All @@ -755,6 +765,11 @@ private FutureCombiner(
* <p>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 <a
* href="https://errorprone.info/bugpattern/FutureReturnValueIgnored">https://errorprone.info/bugpattern/FutureReturnValueIgnored</a>.
*/
public ListenableFuture<?> run(final Runnable combiner, Executor executor) {
return call(
Expand Down

0 comments on commit a7f6b08

Please sign in to comment.