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

BeanFactoryPostProcessor implementations should not be instantiated via constructor dependency injection. #917

Closed
alaneuler opened this issue Mar 1, 2022 · 1 comment

Comments

@alaneuler
Copy link
Contributor

alaneuler commented Mar 1, 2022

In Spring, constructor dependency injection is only available by means of inject-by-type. If BeanFactoryPostProcessor implementations is created via constructor, it will make Spring invoke BeanFactoryUtils.beanNamesForTypeIncludingAncestors to find all suitable candidates. And because of that, bean type unknown unless initialized will be created way early (invokeBeanFactoryPostProcessors phase), e.g., FactoryBean.

Thus we should abandon the usage of creating BeanFactoryPostProcessor implementations via constructor:

  • SofaModuleBeanFactoryPostProcessor
  • RuntimeContextBeanFactoryPostProcessor
  • ServiceBeanFactoryPostProcessor
@alaneuler alaneuler changed the title BeanFactoryPostProcessor implementations should not be instantiated via constructor. BeanFactoryPostProcessor implementations should not be instantiated via constructor dependency injection. Mar 2, 2022
@alaneuler
Copy link
Contributor Author

Similar issue: spring-projects/spring-framework#28122

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants