Repository navigation
Fix application state router isolation across service chains - #16546
xiaobaicai66695 wants to merge 2 commits into
Conversation
Cache application state routers by service key so building another service chain cannot rewrite the first chain's successor. Add regression coverage for both construction orders. Fixes apache#16545
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 3.3 #16546 +/- ##
============================================
- Coverage 60.90% 60.87% -0.03%
Complexity 15 15
============================================
Files 1953 1953
Lines 89280 89273 -7
Branches 13476 13476
============================================
- Hits 54376 54349 -27
- Misses 29323 29340 +17
- Partials 5581 5584 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
EarthChen
left a comment
There was a problem hiding this comment.
LGTM. Confirmed the bug: AppStateRouterFactory cached one router per module, but SingleRouterChain calls setNextRouter on it for each chain, so the chain built last overwrote nextRouter for all earlier chains. Extending CacheableStateRouterFactory (cache by service key) is consistent with the sibling factories. AppStateRouterFactoryTest passes locally.
Non-blocking: the test uses hand-written downstream routers, and the main/backup chains built for the same URL share one cached router instance (harmless today).
What is the purpose of the change?
Fixes #16545.
AppStateRouterFactoryreturned one mutableAppStateRouterfor every service reference in the same module. Building a second service'sSingleRouterChaincallssetNextRouteron that shared object, which changes the first chain's successor. In the linked reproduction, the Order service's application script rule is loaded but its script router is skipped after the User reference is initialized.This change uses the existing
CacheableStateRouterFactoryto cacheAppStateRouterinstances by service key, consistent with the other service and application script router factories. It adds a regression test that builds two service chains in either order and checks that the first chain still filters its invokers after the second chain is built.Verification
AppStateRouterFactoryTestpassed on JDK 8 and JDK 21: 2 tests, 0 failures, 0 errors on each runtime../mvnw -pl dubbo-cluster -am spotless:checkpassed, matching the CI formatting gate.AppStateRouterFactorycompiled from this branch loaded ahead of the Dubbo 3.3.6 runtime, five fresh consumer JVMs each sent 20 Order RPCs and all 20 reached order-v2. The unmodified 3.3.6 control leaked Order calls to order-v1 in all five runs. The complete demo source and rule are in [Bug] Script routing bypassed with two service references #16545.Checklist
9666cb4(formatting, build, license, unit tests on JDK 8/11/17/21/25, samples and integration tests).