Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazily retrieve delegate beans in AsyncConfigurer and CachingConfigurer [SPR-17021] #21559

spring-projects-issues opened this issue Jul 9, 2018 · 1 comment
in: core type: task


Copy link

@spring-projects-issues spring-projects-issues commented Jul 9, 2018

Marcin Grzejszczak opened SPR-17021 and commented

Having such code

public class FrontendAsyncConfigurerSupport extends AsyncConfigurerSupport {

    @Autowired BeanFactory beanFactory;

    public Executor getAsyncExecutor() {
        return beanFactory.getBean(ThreadPoolTaskExecutor.class);

    @Override public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
        return null;
    ThreadPoolTaskExecutor myTaskExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        return executor;

The myTaskExecutor is not applicable to get wrapped via proxy. In Spring Cloud Sleuth we're doing our best so that all instrumentation gets done automatically, behind the scenes. In this case a user has to manually call Sleuth internals to wrap the ThreadPoolTaskExecutor in a tracing representation.

Affects: 5.0.7

Reference URL: spring-cloud/spring-cloud-sleuth#1022

Issue Links:

  • #21484 Doc: AsyncConfigurer causes dependencies to be created early

Referenced from: commits f6fdffd

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jul 9, 2018

Juergen Hoeller commented

A related case has been reported in #21484... While there is not much we can do about that case of triggering hard references to other beans from an AsyncConfigurer class, we should be able to make your case here - Executor post-processing - possible through lazily accessing the executor as well as the exception handler. I'll see what we can do for 5.1 here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
in: core type: task
None yet

No branches or pull requests

2 participants