Declare Callable parameter with nullable type variable

Closes gh-36191
This commit is contained in:
Juergen Hoeller
2026-01-21 19:45:18 +01:00
parent dab28b5dce
commit c05ea841bc
@@ -21,6 +21,8 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import org.jspecify.annotations.Nullable;
import org.springframework.util.concurrent.FutureUtils;
/**
@@ -105,7 +107,7 @@ public interface AsyncTaskExecutor extends TaskExecutor {
* @throws TaskRejectedException if the given task was not accepted
* @since 3.0
*/
default <T> Future<T> submit(Callable<T> task) {
default <T extends @Nullable Object> Future<T> submit(Callable<T> task) {
FutureTask<T> future = new FutureTask<>(task);
execute(future, TIMEOUT_INDEFINITE);
return future;
@@ -132,7 +134,7 @@ public interface AsyncTaskExecutor extends TaskExecutor {
* @throws TaskRejectedException if the given task was not accepted
* @since 6.0
*/
default <T> CompletableFuture<T> submitCompletable(Callable<T> task) {
default <T extends @Nullable Object> CompletableFuture<T> submitCompletable(Callable<T> task) {
return FutureUtils.callAsync(task, this);
}