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

InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation not called for bean declared on JavaConfig [SPR-12140] #16754

spring-projects-issues opened this issue Sep 1, 2014 · 1 comment
in: core type: bug


Copy link

@spring-projects-issues spring-projects-issues commented Sep 1, 2014

Arrault Fabien opened SPR-12140 and commented

When a bean is created with JavaConfig : with a @Bean method without the static modifier (there is another issue with the static modifier : #16756), the method postProcessBeforeInstantiation of InstantiationAwareBeanPostProcessor beans is not called.

See testcase attached

This method is correctly called when the bean is declared in an XML File.

This is one the causes of the troubles of the use of LazyInitTargetSourceCreator on JavaConfig (see #15140)

Affects: 4.0.6


Issue Links:

  • #15140 LazyInitTargetSourceCreator does not work in Java-based configuration ("is depended on by")
  • #16756 InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation called with wrong beanClass for bean declared on JavaConfig

Referenced from: commits b64f680

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 2, 2014

Juergen Hoeller commented

Indeed, we need to call postProcessBeforeInstantiation with a properly resolved bean type, like we do in other places. Up until this point, we simply always took the bean definition's raw bean class... which in the case of a static factory method was at least available (i.e. the class that the factory method is defined on), while for a non-static factory method, it wasn't even there (since they are delegated to a target factory bean by name) - which is why our algorithm didn't even call postProcessBeforeInstantiation (it required the bean class to be non-null). Both cases have been fixed for 4.1 now.


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

No branches or pull requests

2 participants