Skip to content

Commit 3732c71

Browse files
committed
Merge branch '6.1.x'
2 parents 4749d81 + 323de12 commit 3732c71

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

Diff for: spring-aspects/src/main/java/org/springframework/scheduling/aspectj/AnnotationAsyncExecutionAspect.aj

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

Diff for: spring-context/src/main/java/org/springframework/scheduling/annotation/Async.java

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

Diff for: spring-context/src/main/java/org/springframework/scheduling/concurrent/SimpleAsyncTaskScheduler.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@
8080
* but rather just the hand-off to an execution thread.</b> As a consequence,
8181
* a {@link ScheduledFuture} handle (for example, from {@link #schedule(Runnable, Instant)})
8282
* represents that hand-off rather than the actual completion of the provided task
83-
* (or series of repeated tasks).
83+
* (or series of repeated tasks). Also, this scheduler participates in lifecycle
84+
* management to a limited degree only, stopping trigger firing and fixed-delay
85+
* task execution but not stopping the execution of handed-off tasks.
8486
*
8587
* <p>As an alternative to the built-in thread-per-task capability, this scheduler
8688
* can also be configured with a separate target executor for scheduled task

Diff for: spring-core/src/main/java/org/springframework/core/task/SimpleAsyncTaskExecutor.java

+5
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
* executing a large number of short-lived tasks. Alternatively, on JDK 21,
4646
* consider setting {@link #setVirtualThreads} to {@code true}.
4747
*
48+
* <p><b>NOTE: This executor does not participate in context-level lifecycle
49+
* management.</b> Tasks on handed-off execution threads cannot be centrally
50+
* stopped and restarted; if such tight lifecycle management is necessary,
51+
* consider a common {@code ThreadPoolTaskExecutor} setup instead.
52+
*
4853
* @author Juergen Hoeller
4954
* @since 2.0
5055
* @see #setVirtualThreads

0 commit comments

Comments
 (0)