Closed
Description
Affects: 6.0.4
Problem
When an ApplicationContext with a org.springframework.core.task.support.ExecutorServiceAdapter
bean present is closed, the shutdown()
method of ExecutorServiceAdapter
gets called which throws an IllegalStateException
leading to a warning:
Jan. 27, 2023 1:41:44 PM org.springframework.beans.factory.support.DisposableBeanAdapter invokeCustomDestroyMethod
WARNUNG: Custom destroy method 'shutdown' on bean with name 'executorService' threw an exception: java.lang.IllegalStateException: Manual shutdown not supported - ExecutorServiceAdapter is dependent on an external lifecycle
Steps to reproduce
- Configure an ApplicationContext with a
ExecutorServiceAdapter
bean
@Configuration
public class Config {
@Bean
public TaskExecutor taskExecutor() {
return new ThreadPoolTaskExecutor();
}
@Bean
public ExecutorService executorService(TaskExecutor taskExecutor) {
return new ExecutorServiceAdapter(taskExecutor);
}
}
- Start and stop the ApplicationContext:
public class Main {
public static void main(String[] args) {
ConfigurableApplicationContext applicationContext = new AnnotationConfigApplicationContext(Config.class);
applicationContext.getBean("executorService", ExecutorService.class);
applicationContext.close();
}
}
Or have a look at a sample project that reproduces the error.