From 9bc980cd85e6d326d3a3312bec36940e31893541 Mon Sep 17 00:00:00 2001 From: Yanming Zhou Date: Mon, 26 Jan 2026 10:10:26 +0800 Subject: [PATCH] Polish RetryTask 1. Fix wrong type name in assertion message. 2. Rename `retryTemplate` to `retryOperations` to match type better. Signed-off-by: Yanming Zhou --- .../core/retry/support/RetryTask.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/retry/support/RetryTask.java b/spring-core/src/main/java/org/springframework/core/retry/support/RetryTask.java index 0f81aa57984..720619821ef 100644 --- a/spring-core/src/main/java/org/springframework/core/retry/support/RetryTask.java +++ b/spring-core/src/main/java/org/springframework/core/retry/support/RetryTask.java @@ -50,7 +50,7 @@ * @since 7.0.4 * @param the returned value type, if any * @param the exception propagated, if any - * @see RetryTemplate + * @see RetryOperations * @see org.springframework.core.task.SyncTaskExecutor#execute(TaskCallback) * @see org.springframework.core.task.AsyncTaskExecutor#submit(Callable) * @see org.springframework.core.task.AsyncTaskExecutor#submitCompletable(Callable) @@ -59,7 +59,7 @@ public class RetryTask implemen private final TaskCallback task; - private final RetryOperations retryTemplate; + private final RetryOperations retryOperations; /** @@ -86,14 +86,14 @@ public RetryTask(TaskCallback task, RetryPolicy retryPolicy) { /** * Create a new {@code RetryTask} for the given retryable task. * @param task a task that allows for re-execution after failure - * @param retryTemplate the retry delegate to use (typically a {@link RetryTemplate} + * @param retryOperations the retry delegate to use (typically a {@link RetryTemplate} * but declaring the {@link RetryOperations} interface for flexibility) */ - public RetryTask(TaskCallback task, RetryOperations retryTemplate) { + public RetryTask(TaskCallback task, RetryOperations retryOperations) { Assert.notNull(task, "TaskCallback must not be null"); - Assert.notNull(retryTemplate, "RetryTemplate must not be null"); + Assert.notNull(retryOperations, "RetryOperations must not be null"); this.task = task; - this.retryTemplate = retryTemplate; + this.retryOperations = retryOperations; } @@ -101,7 +101,7 @@ public RetryTask(TaskCallback task, RetryOperations retryTemplate) { @Override public V call() throws E { try { - return this.retryTemplate.execute(new Retryable<>() { + return this.retryOperations.execute(new Retryable<>() { @Override public V execute() throws E { return task.call(); @@ -129,7 +129,7 @@ public String getName() { @Override public String toString() { return "RetryTask for " + getName() + " using " + - (this.retryTemplate instanceof RetryTemplate rt ? rt.getRetryPolicy() : this.retryTemplate); + (this.retryOperations instanceof RetryTemplate rt ? rt.getRetryPolicy() : this.retryOperations); } @@ -157,11 +157,11 @@ public static Callable wrap(Callable task, RetryPolicy retryPolicy) { /** * Wrap the given target {@code Callable} into a retrying {@code Callable}. * @param task a task that allows for re-execution after failure - * @param retryTemplate the retry delegate to use (typically a {@link RetryTemplate} + * @param retryOperations the retry delegate to use (typically a {@link RetryTemplate} * but declaring the {@link RetryOperations} interface for flexibility) */ - public static Callable wrap(Callable task, RetryOperations retryTemplate) { - return new RetryTask<>(TaskCallback.from(task), retryTemplate) { + public static Callable wrap(Callable task, RetryOperations retryOperations) { + return new RetryTask<>(TaskCallback.from(task), retryOperations) { @Override public String getName() { return task.getClass().getName(); @@ -193,11 +193,11 @@ public static Runnable wrap(Runnable task, RetryPolicy retryPolicy) { /** * Wrap the given target {@code Runnable} into a retrying {@code Runnable}. * @param task a task that allows for re-execution after failure - * @param retryTemplate the retry delegate to use (typically a {@link RetryTemplate} + * @param retryOperations the retry delegate to use (typically a {@link RetryTemplate} * but declaring the {@link RetryOperations} interface for flexibility) */ - public static Runnable wrap(Runnable task, RetryOperations retryTemplate) { - RetryTask rt = new RetryTask<>(TaskCallback.from(task), retryTemplate) { + public static Runnable wrap(Runnable task, RetryOperations retryOperations) { + RetryTask rt = new RetryTask<>(TaskCallback.from(task), retryOperations) { @Override public String getName() { return task.getClass().getName();