You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "xiincs (via GitHub)" <gi...@apache.org> on 2026/07/31 08:03:32 UTC
[PR] Avoid reference bean name collision with unrelated by-name lookups [dubbo]
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] Avoid reference bean name collision with unrelated by-name lookups [dubbo]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #16405:
URL: https://github.com/apache/dubbo/pull/16405#issuecomment-5140941060
## [Codecov](https://app.codecov.io/gh/apache/dubbo/pull/16405?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `60.00000%` with `2 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 32.19%. Comparing base ([`3a30432`](https://app.codecov.io/gh/apache/dubbo/commit/3a3043227f5571d25eb2889de5bca22f2914843b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`d492932`](https://app.codecov.io/gh/apache/dubbo/commit/d492932989e43c75822649ab62e7efdd3e3f0b2c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing lines](https://app.codecov.io/gh/apache/dubbo/pull/16405?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [...notation/ReferenceAnnotationBeanPostProcessor.java](https://app.codecov.io/gh/apache/dubbo/pull/16405?src=pr&el=tree&filepath=dubbo-config%2Fdubbo-config-spring%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fdubbo%2Fconfig%2Fspring%2Fbeans%2Ffactory%2Fannotation%2FReferenceAnnotationBeanPostProcessor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZHViYm8tY29uZmlnL2R1YmJvLWNvbmZpZy1zcHJpbmcvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2R1YmJvL2NvbmZpZy9zcHJpbmcvYmVhbnMvZmFjdG9yeS9hbm5vdGF0aW9uL1JlZmVyZW5jZUFubm90YXRpb25CZWFuUG9zdFByb2Nlc3Nvci5qYXZh) | 60.00% | [1 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/dubbo/pull/16405?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
> :exclamation: There is a different number of reports uploaded between BASE (3a30432) and HEAD (d492932). Click for more details.
>
> <details><summary>HEAD has 7 uploads less than BASE</summary>
>
>| Flag | BASE (3a30432) | HEAD (d492932) |
>|------|------|------|
>|integration-tests-java21|1|0|
>|integration-tests-java8|1|0|
>|unit-tests-java25|1|0|
>|unit-tests-java8|1|0|
>|unit-tests-java17|1|0|
>|unit-tests-java21|1|0|
>|unit-tests-java11|1|0|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## 3.3 #16405 +/- ##
=============================================
- Coverage 60.87% 32.19% -28.69%
+ Complexity 11766 10229 -1537
=============================================
Files 1953 1952 -1
Lines 89273 89256 -17
Branches 13473 13390 -83
=============================================
- Hits 54346 28735 -25611
- Misses 29333 56301 +26968
+ Partials 5594 4220 -1374
```
| [Flag](https://app.codecov.io/gh/apache/dubbo/pull/16405/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [integration-tests-java21](https://app.codecov.io/gh/apache/dubbo/pull/16405/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [integration-tests-java8](https://app.codecov.io/gh/apache/dubbo/pull/16405/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [samples-tests-java21](https://app.codecov.io/gh/apache/dubbo/pull/16405/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `32.13% <60.00%> (-0.07%)` | :arrow_down: |
| [samples-tests-java8](https://app.codecov.io/gh/apache/dubbo/pull/16405/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `29.74% <60.00%> (-0.06%)` | :arrow_down: |
| [unit-tests-java11](https://app.codecov.io/gh/apache/dubbo/pull/16405/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [unit-tests-java17](https://app.codecov.io/gh/apache/dubbo/pull/16405/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [unit-tests-java21](https://app.codecov.io/gh/apache/dubbo/pull/16405/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [unit-tests-java25](https://app.codecov.io/gh/apache/dubbo/pull/16405/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [unit-tests-java8](https://app.codecov.io/gh/apache/dubbo/pull/16405/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/dubbo/pull/16405?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org