xiincs opened a new pull request, #16405:
URL: https://github.com/apache/dubbo/pull/16405

   ## What is the purpose of the change?
   
   Fixes #12637.
   
   As I understand the issue, when `@DubboReference` has no explicit `id`, the 
reference bean is registered under the bare field name. That name is only 
checked against bean definitions that already exist at registration time, so it 
can later collide with an unrelated bean looked up by the same default name 
elsewhere in the context (for example an independent `@Resource` field). When 
that happens, Spring throws `BeanNotOfRequiredTypeException` instead of falling 
back to by-type resolution, because 
`CommonAnnotationBeanPostProcessor#autowireResource` only takes that fallback 
when no bean of that name exists yet.
   
   While looking into this, I noticed a previous attempt (#15889) touched 
`ReferenceBean#getObjectType()`, but its own regression test still passed on 
unpatched master, so I don't think it ended up exercising the reported scenario 
- hopefully this PR's tests close that gap.
   
   My approach here is an opt-in 
`dubbo.application.qualify-reference-bean-name` property that suffixes 
auto-derived reference bean names so they no longer claim a name an unrelated 
lookup might use. It defaults to `false` so existing naming behavior is 
unchanged for anyone already relying on it - I wasn't confident a 
default-naming change would be safe to make unconditionally given how many 
downstream users this project has, but I'm happy to adjust the approach if 
maintainers see a better way to handle it.
   
   Added `ReferenceBeanNameCollisionTest` (documents the collision under 
default behavior) and `ReferenceBeanNameCollisionFixedTest` (confirms the 
property resolves it), and ran the existing 
`ReferenceAnnotationBeanPostProcessorTest` locally to check for regressions.
   
   This is my first contribution to Dubbo, so please let me know if I've missed 
any conventions.
   
   ## Checklist
   - [x] Make sure there is a 
[GitHub_issue](https://github.com/apache/dubbo/issues) field for the change.
   - [x] Write a pull request description that is detailed enough to understand 
what the pull request does, how, and why.
   - [x] Write necessary unit-test to verify your logic correction. If the new 
feature or significant change is committed, please remember to add sample in 
[dubbo samples](https://github.com/apache/dubbo-samples) project.
   - [x] Make sure gitHub actions can pass. [Why the workflow is failing and 
how to fix it?](../CONTRIBUTING.md)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to