Adjust ThreadPoolTaskScheduler
bean registration to use Integer.MAX_VALUE / 2
phase
#8856
Milestone
ThreadPoolTaskScheduler
bean registration to use Integer.MAX_VALUE / 2
phase
#8856
Starting with Spring Framework
6.1
theExecutorConfigurationSupport
now supports a lifecycle management.It comes with a
private int phase = DEFAULT_PHASE;
.It has this logic:
So, it waits for scheduled tasks to be finished.
The
AbstractPollingEndpoint
usesInteger.MAX_VALUE / 2
and callsthis.runningTask.cancel(true);
in itsstop()
. So, no new messages are emitted to the application.However this combination leads to dead-lock and unexpected behavior.
According to the phase logic
The
ThreadPoolTaskScheduler
is stopped earlier, thenPollingConsumer
.And the former waits for its tasks to be finished, not giving the later a chance to cancel its task.
Therefore the
ThreadPoolTaskScheduler
configuration in theDefaultConfiguringBeanFactoryPostProcessor.registerTaskScheduler()
should be adjusted to use the sameInteger.MAX_VALUE / 2
phase.The text was updated successfully, but these errors were encountered: