diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfig.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfig.java index 235eeca6adf..74e51f44892 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfig.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfig.java @@ -55,7 +55,6 @@ import org.springframework.scheduling.concurrent.ScheduledExecutorFactoryBean; import org.springframework.scheduling.config.ScheduledTaskRegistrar; import javax.annotation.Nonnull; -import java.util.concurrent.ScheduledExecutorService; @Configuration @@ -112,11 +111,11 @@ public abstract class BaseConfig implements SchedulingConfigurer { } @Bean() - public ScheduledExecutorService scheduledExecutorService() { + public ScheduledExecutorFactoryBean scheduledExecutorService() { ScheduledExecutorFactoryBean b = new ScheduledExecutorFactoryBean(); b.setPoolSize(5); b.afterPropertiesSet(); - return b.getObject(); + return b; } @Bean(name = "mySubscriptionTriggeringProvider") @@ -166,16 +165,16 @@ public abstract class BaseConfig implements SchedulingConfigurer { @Bean() public TaskScheduler taskScheduler() { ConcurrentTaskScheduler retVal = new ConcurrentTaskScheduler(); - retVal.setConcurrentExecutor(scheduledExecutorService()); - retVal.setScheduledExecutor(scheduledExecutorService()); + retVal.setConcurrentExecutor(scheduledExecutorService().getObject()); + retVal.setScheduledExecutor(scheduledExecutorService().getObject()); return retVal; } @Bean(name = TASK_EXECUTOR_NAME) public AsyncTaskExecutor taskExecutor() { ConcurrentTaskScheduler retVal = new ConcurrentTaskScheduler(); - retVal.setConcurrentExecutor(scheduledExecutorService()); - retVal.setScheduledExecutor(scheduledExecutorService()); + retVal.setConcurrentExecutor(scheduledExecutorService().getObject()); + retVal.setScheduledExecutor(scheduledExecutorService().getObject()); return retVal; }