Align submit(Callable) delegation in AsyncTaskExecutor#36557
Closed
bebeis wants to merge 0 commit intospring-projects:mainfrom
Closed
Align submit(Callable) delegation in AsyncTaskExecutor#36557bebeis wants to merge 0 commit intospring-projects:mainfrom
bebeis wants to merge 0 commit intospring-projects:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AsyncTaskExecutor.submit(Callable)currently documents that, as of 6.1, its default implementation delegates toexecute(Runnable).However, the implementation still invokes the deprecated
execute(Runnable, long)variant withTIMEOUT_INDEFINITE.This change aligns the default
submit(Callable)implementation with:submit(Runnable)implementation, andexecute(Runnable, long).Historical Context
execute(Runnable, long)was deprecated earlier because commonAsyncTaskExecutorimplementations do not meaningfully support start timeouts. (see gh-27959)Later, in 6.1, default implementations were introduced for both
submit(Runnable)andsubmit(Callable), with Javadoc stating delegation toexecute(Runnable). Whilesubmit(Runnable)follows that contract,submit(Callable)still routes throughexecute(Runnable, long).This change brings
submit(Callable)in line with that 6.1 contract and restores consistency between the two defaultsubmit(...)variants.Regression Test
A regression test has been added to verify the default dispatch path.
For an
AsyncTaskExecutorimplementation that:submit(Callable)implementation, andexecute(Runnable)andexecute(Runnable, long),the test now verifies that
submit(Callable)delegates toexecute(Runnable)rather thanexecute(Runnable, long).Impact
Within Spring Framework itself, this does not affect the built-in
AsyncTaskExecutorimplementations.Executors with specialized submission behavior already override
submit(Callable), andVirtualThreadTaskExecutoronly implementsexecute(Runnable), so the effective behavior remains unchanged there.For external
AsyncTaskExecutorimplementations that inherit the defaultsubmit(Callable)implementation and overrideexecute(Runnable, long), this changes the default dispatch path fromexecute(Runnable, long)toexecute(Runnable).That change is intentional here, to make the default implementation consistent with its documented 6.1 behavior.