Affects: 6.1.3
As discussed with @jhoeller, https://github.com/spring-projects/spring-boot/issues/39469 has highlighted a problem with ThreadPoolTaskExecutor
rejecting tasks once it has received a ContextClosedEvent
. In a Spring Boot web application this creates a window where the task executor cannot be used but the web server is still accepting requests. Those requests will fail if they try to use the executor.
Comment From: jhoeller
ThreadPoolTaskExecutor
(and also ThreadPoolExecutorFactoryBean
) leniently accepts tasks after context close in combination with the coordinated lifecycle stop phase now. So this is not setAcceptTasksAfterContextClose(true)
by default (which would bypass the lifecycle stop phase altogether) but rather lenient acceptance of further tasks which will nevertheless be rolled into the lifecycle stop phase, waiting for all such late submissions to complete still, resulting in a lenient variant of a graceful shutdown.
Schedulers remain strict on shutdown (otherwise the triggers would keep firing while we wait for all tasks to complete), just plain executors are lenient on shutdown now. An early shutdown for executors with strict rejecting of further task submissions can be enforced via setStrictEarlyShutdown(true)
.