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

Doc: AsyncConfigurer causes dependencies to be created early [SPR-16945] #21484

Closed
spring-projects-issues opened this issue Jun 15, 2018 · 0 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: documentation A documentation task
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jun 15, 2018

Petr Stuchlik opened SPR-16945 and commented

JavaDoc for @EnableAsync suggests implementing AsyncConfigurer to customize AsyncUncaughtExceptionHandler. This works fine and one would typically extend AsyncConfigurerSupport in his configuration class. This can, however, lead to a rather nasty issue (or difficult-to-debug at least) when also expressing a direct bean dependency in this configuration class.

The issue is that this dependency causes the bean (and all its dependencies) to be created very early - at the time when BeanPostProcessors are registered. That prevents these beans to be processed (e.g. by AspectJ processors).

This happens because ProxyAsyncConfiguration finds the AsyncConfigurer and causes this config to be created along with its dependencies, when other processors are not available yet.

For workaround, one can often annotate the bean dependency in the config as @Lazy.

After lengthy investigation why my beans are not CGLIB-proxied I've found this cause. Having learned how the ProxyAsyncConfiguration is bootstrapped I no longer find this behavior surprising. But if this was stated somewhere in the JavaDoc at least I'd have more hair on my head at this moment.

You can see the referenced PoC on GitHub for more details.


Affects: 4.3.18, 5.0.7

Reference URL: https://github.com/stuchl4n3k/spring-async-configurer-issue

Issue Links:

Backported to: 4.3.19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: documentation A documentation task
Projects
None yet
Development

No branches or pull requests

2 participants