-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancementA general enhancement
Milestone
Description
Grzegorz Grzybek opened SPR-9280 and commented
Javadoc for @EnableScheduling has the following code example:
@Configuration
@EnableScheduling
public class AppConfig implements SchedulingConfigurer {
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
taskRegistrar.setScheduler(taskExecutor());
}
@Bean
public Executor taskExecutor() {
return Executors.newScheduledThreadPool(100);
}
}With such @Bean definition (taskExecutor), the returned bean cannot be properly destroyed while closing the appcontext - returned TaskSheduler have "shutdown" method, but it cannot be invoked using "(inferred)" mechanism. So with e.g., web application it causes memory leaks.
Please either
- change "taskExecutor" definition to return org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler, or
- use
@Bean(destroyMethod = "shutdown")
one more thing - I have strange issues with:
@Bean(destroyMethod = "shutdown")
public Executor springTaskScheduler()
{
return Executors.newScheduledThreadPool(10);
}because although shutdown() is called, some classes from Spring (in heap dump) appear to have been on "native stack" (e.g., org.springframework.aop.framework.autoproxy.InfrastructureAdvisorAutoProxyCreator) - more on this on Spring Forum (soon)
regards
Grzegorz Grzybek
Affects: 3.1.1
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancementA general enhancement