-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchesAn issue that has been backported to maintenance branchestype: bugA general bugA general bug
Milestone
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
ExecutorServiceAdapterbean
@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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchesAn issue that has been backported to maintenance branchestype: bugA general bugA general bug