mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-26 08:59:09 +00:00
The taskTerminationTimeoutWithImmediateCancel test submitted a task and immediately closed the executor, then asserted that the future was cancelled. The cancellation flag is set by close() on the calling thread, while it is checked at the start of the task on a separate worker thread. With no ordering guarantee between the two, a quickly scheduled worker could pass the cancellation check before close() set the flag, complete the trivial task normally, and leave the future uncancelled, making the test fail intermittently under load. Override doExecute to capture the task-tracking wrapper instead of running it on a background thread, then run it on the test thread after close() has set the cancellation flag. This exercises the same cancellation path deterministically, with no reliance on thread scheduling. Signed-off-by: junhyeong9812 <pickjog@gmail.com>