I have a small standalone application that configures the scheduler to terminate gracefully. With the following configuration:
@Bean
public TaskScheduler taskScheduler() {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setWaitForTasksToCompleteOnShutdown(true);
scheduler.setAwaitTerminationSeconds(60);
return scheduler;
}
I can get it to gracefully terminate the scheduler, but only if I don't have any @Scheduled(cron = ) task. Once I have one of those, no matter what the scheduler will get stuck until timeout. I already tried configuring it also with an executor and do the shutdown/await manually and the effect is exactly the same.
These cron jobs are not even running. They are set to run at a fixed time during the night for example.
Spring version: 4.2.8.RELEASE
This will happen when the timeout reaches the end:
2017.07.28 01:44:56 [Thread-3] WARN Timed out while waiting for executor 'taskScheduler' to terminate
Any thoughts?