support config ReferenceBean by the way of static @Bean method or @Bean method in @Component java config #9653
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
There exists bug when config ReferenceBean by the way of static @bean method or @bean method in @component java config. You can run the following two tests in this pr:
Brief changelog
The original author use beanFactory#getType() as the ReferenceConfig's interface name, which may cause early instantiation but get null objectType in the case of static @bean method or @bean method in @component java config bean to build ReferenceBean.
Here I modify the above logic and just get the return generic type as interface name from the @bean method at the registry time. And all the config ReferenceBean case with @bean method is supported, the original usage is also compatible. When the ReferenceBean is configured in the same method name, I just get common ancestor of return generic type here like the spring internals do.
Verifying this change
Checklist