Exclusively mention CompletableFuture instead of ListenableFuture

Closes gh-33805
This commit is contained in:
Juergen Hoeller 2024-10-28 22:05:10 +01:00
parent e340e45f5a
commit 94d46eba3c
2 changed files with 16 additions and 15 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -28,10 +28,10 @@ import org.springframework.scheduling.annotation.Async;
* <p>This aspect routes methods marked with the {@link Async} annotation as well as methods * <p>This aspect routes methods marked with the {@link Async} annotation as well as methods
* in classes marked with the same. Any method expected to be routed asynchronously must * in classes marked with the same. Any method expected to be routed asynchronously must
* return either {@code void}, {@link Future}, or a subtype of {@link Future} (in particular, * return either {@code void}, {@link Future}, or a subtype of {@link Future} (in particular,
* Spring's {@link org.springframework.util.concurrent.ListenableFuture}). This aspect, * {@link java.util.concurrent.CompletableFuture}). This aspect, therefore, will produce a
* therefore, will produce a compile-time error for methods that violate this constraint * compile-time error for methods that violate this constraint on the return type. If,
* on the return type. If, however, a class marked with {@code @Async} contains a method * however, a class marked with {@code @Async} contains a method that violates this
* that violates this constraint, it produces only a warning. * constraint, it produces only a warning.
* *
* <p>This aspect needs to be injected with an implementation of a task-oriented * <p>This aspect needs to be injected with an implementation of a task-oriented
* {@link java.util.concurrent.Executor} to activate it for a specific thread pool, * {@link java.util.concurrent.Executor} to activate it for a specific thread pool,

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2022 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -35,17 +35,18 @@ import org.springframework.aot.hint.annotation.Reflective;
* <p>In terms of target method signatures, any parameter types are supported. * <p>In terms of target method signatures, any parameter types are supported.
* However, the return type is constrained to either {@code void} or * However, the return type is constrained to either {@code void} or
* {@link java.util.concurrent.Future}. In the latter case, you may declare the * {@link java.util.concurrent.Future}. In the latter case, you may declare the
* more specific {@link org.springframework.util.concurrent.ListenableFuture} or * more specific {@link java.util.concurrent.CompletableFuture} type which allows
* {@link java.util.concurrent.CompletableFuture} types which allow for richer * for richer interaction with the asynchronous task and for immediate composition
* interaction with the asynchronous task and for immediate composition with * with further processing steps.
* further processing steps.
* *
* <p>A {@code Future} handle returned from the proxy will be an actual asynchronous * <p>A {@code Future} handle returned from the proxy will be an actual asynchronous
* {@code Future} that can be used to track the result of the asynchronous method * {@code (Completable)Future} that can be used to track the result of the
* execution. However, since the target method needs to implement the same signature, * asynchronous method execution. However, since the target method needs to implement
* it will have to return a temporary {@code Future} handle that just passes a value * the same signature, it will have to return a temporary {@code Future} handle that
* through: for example, Spring's {@link AsyncResult}, EJB 3.1's {@link jakarta.ejb.AsyncResult}, * just passes a value after computation in the execution thread: typically through
* or {@link java.util.concurrent.CompletableFuture#completedFuture(Object)}. * {@link java.util.concurrent.CompletableFuture#completedFuture(Object)}. The
* provided value will be exposed to the caller through the actual asynchronous
* {@code Future} handle at runtime.
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @author Chris Beams * @author Chris Beams