Skip to content

Commit 07a18c8

Browse files
committed
Refine Task Javadoc about Runnable wrapping
Clarify that the runnable associated with a Task may be wrapped by the framework (for scheduling or observability). The runnable returned by getRunnable() is the one to execute, and it may differ from the original instance supplied by the user. Closes #35394 Signed-off-by: Gennaro Rascato <[email protected]> fix Signed-off-by: Gennaro Rascato <[email protected]>
1 parent b741632 commit 07a18c8

File tree

1 file changed

+11
-0
lines changed
  • spring-context/src/main/java/org/springframework/scheduling/config

1 file changed

+11
-0
lines changed

spring-context/src/main/java/org/springframework/scheduling/config/Task.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@
2626
* Holder class defining a {@code Runnable} to be executed as a task, typically at a
2727
* scheduled time or interval. See subclass hierarchy for various scheduling approaches.
2828
*
29+
* <p><strong>Note:</strong> this is not merely a holder for the user-provided
30+
* {@code Runnable}. The framework may wrap the runnable instance for scheduling
31+
* or observability purposes (for example with {@code OutcomeTrackingRunnable},
32+
* {@code SchedulingAwareRunnable}, or {@code SubscribingRunnable}). The runnable
33+
* returned by {@link #getRunnable()} is the one to execute, and it may differ
34+
* from the original object supplied by the user.
35+
*
2936
* @author Chris Beams
3037
* @author Juergen Hoeller
3138
* @author Brian Clozel
@@ -40,6 +47,8 @@ public class Task {
4047

4148
/**
4249
* Create a new {@code Task}.
50+
* <p>The provided runnable may be wrapped by the framework; see the class-level
51+
* Javadoc for details.
4352
* @param runnable the underlying task to execute
4453
*/
4554
public Task(Runnable runnable) {
@@ -51,6 +60,8 @@ public Task(Runnable runnable) {
5160

5261
/**
5362
* Return the underlying task.
63+
* <p>Note that this may be a framework wrapper around the original runnable
64+
* supplied at construction time.
5465
*/
5566
public Runnable getRunnable() {
5667
return this.runnable;

0 commit comments

Comments
 (0)