Repository navigation
Fix application script routing after rule deletion - #16549
xiaobaicai66695 wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 3.3 #16549 +/- ##
============================================
+ Coverage 60.90% 60.92% +0.01%
- Complexity 15 30 +15
============================================
Files 1953 1953
Lines 89280 89286 +6
Branches 13476 13478 +2
============================================
+ Hits 54376 54394 +18
+ Misses 29323 29311 -12
Partials 5581 5581
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: after a rule is deleted, scriptRule is null but scriptRouter stays non-null, so doRoute hits an NPE on scriptRule.isValid(). Merging rule and router into one immutable RouterState published through a volatile field fixes it and removes the null-check/dereference race. A failed ScriptStateRouter construction now keeps the old state.
Verified locally: AppScriptStateRouterTest passes with this PR, and fails with an NPE in doRoute when the main class is reverted to 3.3.
What does this PR do?
Fixes #16548.
DELETEDevent arrives, so routing passes through to the healthy provider candidates.Why?
In 3.3.6,
AppScriptStateRouter.process(DELETED)clearsscriptRulebut leavesscriptRouternon-null. The next invocation passes the null-router guard and dereferencesscriptRule.isValid().DynamicDirectorycatches the exception and returns an empty invoker list, causingNo provider availableeven when providers are healthy. Publishing the rule and compiled router together also prevents an invocation from observing values from different configuration revisions.This bug reproduces with a single service reference on unmodified 3.3.6. It is independent of the cross-service chain issue in #16545 and #16546.
How was this tested?
AppScriptStateRouterTestcase fails with aNullPointerExceptionatdoRouteon unmodified 3.3 source, then passes with this change../mvnw -pl dubbo-cluster -Dtest=AppScriptStateRouterTest -Dsurefire.failIfNoSpecifiedTests=false test: 2 tests, 0 failures, 0 errors.No production cluster changes are included in this PR.