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

support config ReferenceBean by the way of static @Bean method or @Bean method in @Component java config #9653

Open
wants to merge 2 commits into
base: 3.0
Choose a base branch
from

Conversation

jessin20161124
Copy link
Contributor

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:

  • dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/conditional5/JavaConfigReferenceBeanConditionalTest5.java
  • dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/conditional7/JavaConfigReferenceBeanConditionalTest7.java

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

  • dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/conditional5/JavaConfigReferenceBeanConditionalTest5.java
  • dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/conditional5/JavaConfigReferenceBeanConditionalTest6.java
  • dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/conditional7/JavaConfigReferenceBeanConditionalTest7.java

Checklist

  • Make sure there is a GitHub_issue field for the change (usually before you start working on it). Trivial changes like typos do not require a GitHub issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Check if is necessary to patch to Dubbo 3 if you are work on Dubbo 2.7
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
  • Add some description to dubbo-website project if you are requesting to add a feature.
  • GitHub Actions works fine on your own branch.
  • If this contribution is large, please follow the Software Donation Guide.

@jessin20161124
Copy link
Contributor Author

Any feedback regarding this pr? @AlbumenJ @chickenlj

@jessin20161124
Copy link
Contributor Author

Any feedback about this pr? @AlbumenJ @chickenlj

@chickenlj chickenlj requested a review from kylixs March 17, 2022 06:56
@chickenlj chickenlj added this to the 3.0.7 milestone Mar 17, 2022
@chickenlj chickenlj modified the milestones: 3.0.7, 3.0.8 Mar 28, 2022
@chickenlj chickenlj modified the milestones: 3.0.8, 3.0.9 May 12, 2022
@AlbumenJ AlbumenJ modified the milestones: 3.0.9, 3.0.10 Jun 20, 2022
@AlbumenJ AlbumenJ modified the milestones: 3.0.10, 3.0.11 Jul 16, 2022
@AlbumenJ AlbumenJ modified the milestones: 3.0.11, 3.0.12 Aug 16, 2022
@AlbumenJ AlbumenJ modified the milestones: 3.0.12, 3.0.13 Sep 29, 2022
@CrazyHZM CrazyHZM removed this from the 3.0.13 milestone Dec 21, 2023
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

Successfully merging this pull request may close these issues.

4 participants