diff --git a/org.springframework.context/src/main/java/org/springframework/scheduling/config/TaskExecutorFactoryBean.java b/org.springframework.context/src/main/java/org/springframework/scheduling/config/TaskExecutorFactoryBean.java index 3cc04ef4ed..a51748dacd 100644 --- a/org.springframework.context/src/main/java/org/springframework/scheduling/config/TaskExecutorFactoryBean.java +++ b/org.springframework.context/src/main/java/org/springframework/scheduling/config/TaskExecutorFactoryBean.java @@ -20,6 +20,7 @@ import org.springframework.beans.BeanWrapper; import org.springframework.beans.BeanWrapperImpl; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanNameAware; +import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.core.JdkVersion; @@ -33,7 +34,7 @@ import org.springframework.util.StringUtils; * @author Mark Fisher * @since 3.0 */ -public class TaskExecutorFactoryBean implements FactoryBean, BeanNameAware { +public class TaskExecutorFactoryBean implements FactoryBean, BeanNameAware, DisposableBean { private volatile TaskExecutor target; @@ -89,6 +90,12 @@ public class TaskExecutorFactoryBean implements FactoryBean, BeanN public boolean isSingleton() { return true; } + + public void destroy() throws Exception { + if (this.target instanceof DisposableBean) { + ((DisposableBean) this.target).destroy(); + } + } private void initializeExecutor() throws Exception { synchronized (this.initializationMonitor) {