Skip to content

Commit

Permalink
Added @DonotCall to Futures methods which do not take an executor
Browse files Browse the repository at this point in the history
Futures methods which run a callback and do not accept an Executor will be removed in a future release.  @DonotCall has been added to these methods to prevent their use until that time.

For more information, see []
RELNOTES=`util.concurrent`: Added @DonotCall to Futures methods that do not accept an Executor in preparation for removal

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=196905403
  • Loading branch information
jlavallee authored and cpovirk committed May 23, 2018
1 parent f972c21 commit 49a1df6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.google.common.util.concurrent.ImmediateFuture.ImmediateSuccessfulCheckedFuture;
import com.google.common.util.concurrent.ImmediateFuture.ImmediateSuccessfulFuture;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotCall;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.Callable;
Expand Down Expand Up @@ -322,6 +323,7 @@ public void run() {
* documentation. This method is scheduled to be removed in July 2018.
*/
@Deprecated
@DoNotCall
@Partially.GwtIncompatible("AVAILABLE but requires exceptionType to be Throwable.class")
public static <V, X extends Throwable> ListenableFuture<V> catching(
ListenableFuture<? extends V> input,
Expand Down Expand Up @@ -442,6 +444,7 @@ public static <V, X extends Throwable> ListenableFuture<V> catching(
*/
@CanIgnoreReturnValue // TODO(kak): @CheckReturnValue
@Deprecated
@DoNotCall
@Partially.GwtIncompatible("AVAILABLE but requires exceptionType to be Throwable.class")
public static <V, X extends Throwable> ListenableFuture<V> catchingAsync(
ListenableFuture<? extends V> input,
Expand Down Expand Up @@ -582,6 +585,7 @@ public static <V> ListenableFuture<V> withTimeout(
* documentation. This method is scheduled to be removed in July 2018.
*/
@Deprecated
@DoNotCall
public static <I, O> ListenableFuture<O> transformAsync(
ListenableFuture<I> input, AsyncFunction<? super I, ? extends O> function) {
return AbstractTransformFuture.create(input, function, directExecutor());
Expand Down Expand Up @@ -666,6 +670,7 @@ public static <I, O> ListenableFuture<O> transformAsync(
* scheduled to be removed in July 2018.
*/
@Deprecated
@DoNotCall
public static <I, O> ListenableFuture<O> transform(
ListenableFuture<I> input, Function<? super I, ? extends O> function) {
return AbstractTransformFuture.create(input, function, directExecutor());
Expand Down Expand Up @@ -923,6 +928,7 @@ public <C> ListenableFuture<C> callAsync(AsyncCallable<C> combiner, Executor exe
* scheduled to be removed in July 2018.
*/
@Deprecated
@DoNotCall
public <C> ListenableFuture<C> callAsync(AsyncCallable<C> combiner) {
return callAsync(combiner, directExecutor());
}
Expand Down Expand Up @@ -958,6 +964,7 @@ public <C> ListenableFuture<C> call(Callable<C> combiner, Executor executor) {
*/
@CanIgnoreReturnValue // TODO(cpovirk): Remove this
@Deprecated
@DoNotCall
public <C> ListenableFuture<C> call(Callable<C> combiner) {
return call(combiner, directExecutor());
}
Expand Down Expand Up @@ -1271,6 +1278,7 @@ private void recordCompletion() {
* documentation. This method is scheduled to be removed in July 2018.
*/
@Deprecated
@DoNotCall
public static <V> void addCallback(
ListenableFuture<V> future, FutureCallback<? super V> callback) {
addCallback(future, callback, directExecutor());
Expand Down
8 changes: 8 additions & 0 deletions guava/src/com/google/common/util/concurrent/Futures.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.google.common.util.concurrent.ImmediateFuture.ImmediateSuccessfulCheckedFuture;
import com.google.common.util.concurrent.ImmediateFuture.ImmediateSuccessfulFuture;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotCall;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.Callable;
Expand Down Expand Up @@ -322,6 +323,7 @@ public void run() {
* documentation. This method is scheduled to be removed in July 2018.
*/
@Deprecated
@DoNotCall
@Partially.GwtIncompatible("AVAILABLE but requires exceptionType to be Throwable.class")
public static <V, X extends Throwable> ListenableFuture<V> catching(
ListenableFuture<? extends V> input,
Expand Down Expand Up @@ -442,6 +444,7 @@ public static <V, X extends Throwable> ListenableFuture<V> catching(
*/
@CanIgnoreReturnValue // TODO(kak): @CheckReturnValue
@Deprecated
@DoNotCall
@Partially.GwtIncompatible("AVAILABLE but requires exceptionType to be Throwable.class")
public static <V, X extends Throwable> ListenableFuture<V> catchingAsync(
ListenableFuture<? extends V> input,
Expand Down Expand Up @@ -582,6 +585,7 @@ public static <V> ListenableFuture<V> withTimeout(
* documentation. This method is scheduled to be removed in July 2018.
*/
@Deprecated
@DoNotCall
public static <I, O> ListenableFuture<O> transformAsync(
ListenableFuture<I> input, AsyncFunction<? super I, ? extends O> function) {
return AbstractTransformFuture.create(input, function, directExecutor());
Expand Down Expand Up @@ -666,6 +670,7 @@ public static <I, O> ListenableFuture<O> transformAsync(
* scheduled to be removed in July 2018.
*/
@Deprecated
@DoNotCall
public static <I, O> ListenableFuture<O> transform(
ListenableFuture<I> input, Function<? super I, ? extends O> function) {
return AbstractTransformFuture.create(input, function, directExecutor());
Expand Down Expand Up @@ -923,6 +928,7 @@ public <C> ListenableFuture<C> callAsync(AsyncCallable<C> combiner, Executor exe
* scheduled to be removed in July 2018.
*/
@Deprecated
@DoNotCall
public <C> ListenableFuture<C> callAsync(AsyncCallable<C> combiner) {
return callAsync(combiner, directExecutor());
}
Expand Down Expand Up @@ -958,6 +964,7 @@ public <C> ListenableFuture<C> call(Callable<C> combiner, Executor executor) {
*/
@CanIgnoreReturnValue // TODO(cpovirk): Remove this
@Deprecated
@DoNotCall
public <C> ListenableFuture<C> call(Callable<C> combiner) {
return call(combiner, directExecutor());
}
Expand Down Expand Up @@ -1271,6 +1278,7 @@ private void recordCompletion() {
* documentation. This method is scheduled to be removed in July 2018.
*/
@Deprecated
@DoNotCall
public static <V> void addCallback(
ListenableFuture<V> future, FutureCallback<? super V> callback) {
addCallback(future, callback, directExecutor());
Expand Down

0 comments on commit 49a1df6

Please sign in to comment.