Skip to content

Commit

Permalink
Remove @Beta from uncontroversial Futures methods:
Browse files Browse the repository at this point in the history
- `submit`
- `submitAsync`
- `scheduleAsync`
- `nonCancellationPropagating`
- `inCompletionOrder`

I did also add a TODO to potentially make the return type of `scheduleAsync` more specific in the future. However, to the best of my knowledge, no one has ever asked for this. (That's not surprising: `ScheduledFuture` isn't any more useful than `Future` unless you're implementing a `ScheduledExecutorService`, and even then, access to its timeout is unavoidably racy.) Plus, should we ever need to do it, we can do it compatibly by injecting a bridge method with the old signature.

(I didn't see any discussion of the return type in the API Review doc or the CL review thread. It probably just didn't come up, or maybe we all independently concluded that it wasn't worth the trouble, given that `MoreExecutors.listeningDecorator(ScheduledExecutorService)` is a bit of a pain? But I'm guessing `scheduleAsync` would be easier.)

RELNOTES=`util.concurrent`: Removed `@Beta` from `Futures` methods: `submit`, `submitAsync`, `scheduleAsync`, `nonCancellationPropagating`, `inCompletionOrder`.
PiperOrigin-RevId: 416139691
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Dec 13, 2021
1 parent 9c7e13b commit e015172
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ private Futures() {}
* @throws RejectedExecutionException if the task cannot be scheduled for execution
* @since 28.2
*/
@Beta
public static <O extends @Nullable Object> ListenableFuture<O> submit(
Callable<O> callable, Executor executor) {
TrustedListenableFutureTask<O> task = TrustedListenableFutureTask.create(callable);
Expand All @@ -194,7 +193,6 @@ private Futures() {}
* @throws RejectedExecutionException if the task cannot be scheduled for execution
* @since 28.2
*/
@Beta
public static ListenableFuture<@Nullable Void> submit(Runnable runnable, Executor executor) {
TrustedListenableFutureTask<@Nullable Void> task =
TrustedListenableFutureTask.create(runnable, null);
Expand All @@ -208,7 +206,6 @@ private Futures() {}
* @throws RejectedExecutionException if the task cannot be scheduled for execution
* @since 23.0
*/
@Beta
public static <O extends @Nullable Object> ListenableFuture<O> submitAsync(
AsyncCallable<O> callable, Executor executor) {
TrustedListenableFutureTask<O> task = TrustedListenableFutureTask.create(callable);
Expand All @@ -222,9 +219,9 @@ private Futures() {}
* @throws RejectedExecutionException if the task cannot be scheduled for execution
* @since 23.0
*/
@Beta
@GwtIncompatible // java.util.concurrent.ScheduledExecutorService
@SuppressWarnings("GoodTime") // should accept a java.time.Duration
// TODO(cpovirk): Return ListenableScheduledFuture?
public static <O extends @Nullable Object> ListenableFuture<O> scheduleAsync(
AsyncCallable<O> callable,
long delay,
Expand Down Expand Up @@ -743,7 +740,6 @@ public Void call() throws Exception {
*
* @since 15.0
*/
@Beta
public static <V extends @Nullable Object> ListenableFuture<V> nonCancellationPropagating(
ListenableFuture<V> future) {
if (future.isDone()) {
Expand Down Expand Up @@ -871,7 +867,6 @@ protected void afterDone() {
*
* @since 17.0
*/
@Beta
public static <T extends @Nullable Object> ImmutableList<ListenableFuture<T>> inCompletionOrder(
Iterable<? extends ListenableFuture<? extends T>> futures) {
ListenableFuture<? extends T>[] copy = gwtCompatibleToArray(futures);
Expand Down
9 changes: 2 additions & 7 deletions guava/src/com/google/common/util/concurrent/Futures.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ private Futures() {}
* @throws RejectedExecutionException if the task cannot be scheduled for execution
* @since 28.2
*/
@Beta
public static <O extends @Nullable Object> ListenableFuture<O> submit(
Callable<O> callable, Executor executor) {
TrustedListenableFutureTask<O> task = TrustedListenableFutureTask.create(callable);
Expand All @@ -196,7 +195,6 @@ private Futures() {}
* @throws RejectedExecutionException if the task cannot be scheduled for execution
* @since 28.2
*/
@Beta
public static ListenableFuture<@Nullable Void> submit(Runnable runnable, Executor executor) {
TrustedListenableFutureTask<@Nullable Void> task =
TrustedListenableFutureTask.create(runnable, null);
Expand All @@ -210,7 +208,6 @@ private Futures() {}
* @throws RejectedExecutionException if the task cannot be scheduled for execution
* @since 23.0
*/
@Beta
public static <O extends @Nullable Object> ListenableFuture<O> submitAsync(
AsyncCallable<O> callable, Executor executor) {
TrustedListenableFutureTask<O> task = TrustedListenableFutureTask.create(callable);
Expand All @@ -224,8 +221,8 @@ private Futures() {}
* @throws RejectedExecutionException if the task cannot be scheduled for execution
* @since 28.0
*/
@Beta
@GwtIncompatible // java.util.concurrent.ScheduledExecutorService
// TODO(cpovirk): Return ListenableScheduledFuture?
public static <O extends @Nullable Object> ListenableFuture<O> scheduleAsync(
AsyncCallable<O> callable, Duration delay, ScheduledExecutorService executorService) {
return scheduleAsync(callable, toNanosSaturated(delay), TimeUnit.NANOSECONDS, executorService);
Expand All @@ -237,9 +234,9 @@ private Futures() {}
* @throws RejectedExecutionException if the task cannot be scheduled for execution
* @since 23.0
*/
@Beta
@GwtIncompatible // java.util.concurrent.ScheduledExecutorService
@SuppressWarnings("GoodTime") // should accept a java.time.Duration
// TODO(cpovirk): Return ListenableScheduledFuture?
public static <O extends @Nullable Object> ListenableFuture<O> scheduleAsync(
AsyncCallable<O> callable,
long delay,
Expand Down Expand Up @@ -776,7 +773,6 @@ public Void call() throws Exception {
*
* @since 15.0
*/
@Beta
public static <V extends @Nullable Object> ListenableFuture<V> nonCancellationPropagating(
ListenableFuture<V> future) {
if (future.isDone()) {
Expand Down Expand Up @@ -904,7 +900,6 @@ protected void afterDone() {
*
* @since 17.0
*/
@Beta
public static <T extends @Nullable Object> ImmutableList<ListenableFuture<T>> inCompletionOrder(
Iterable<? extends ListenableFuture<? extends T>> futures) {
ListenableFuture<? extends T>[] copy = gwtCompatibleToArray(futures);
Expand Down

0 comments on commit e015172

Please sign in to comment.