cvictory opened a new pull request, #3313:
URL: https://github.com/apache/dubbo-go/pull/3313
## Bug
- **Symptom**: When Polaris only has uid-based route rules without discovery
fallback, consumer gets `RouteRuleNotMatch` followed by nil pointer panic.
- **Root cause**: `Route()` in `cluster/router/polaris/router.go` returns an
empty invoker slice when `ProcessRouters` returns instances that don't map to
any known invoker. The empty slice propagates to cluster invokers (failfast,
failover, etc.) which access `invokers[0]`, causing nil pointer panic.
## Fix
After building the result from `ProcessRouters` response, if the result is
empty (no matching invokers), log a warning and return the original invokers as
a safe fallback. This follows the same defensive pattern used in 5 other error
paths in the same method.
**Changed files:**
- `cluster/router/polaris/router.go` — 4-line empty-result guard
- `cluster/router/polaris/router_test.go` — 7 new regression tests with mock
infrastructure
## Verification
- Tests: 13/13 pass (6 existing + 7 new)
- `go vet`: clean
- `go build`: clean
- Key regression tests:
- `TestRouteRuleNotMatchFallbackToOriginalInvokers` — non-matching
instances → fallback
- `TestRouteEmptyProcessRoutersResultFallbackToOriginalInvokers` — empty
result → fallback
- `TestRouteHappyPathReturnsMatchedInvokers` — matching instances →
filtered (behavior preserved)
Closes #3303
--
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]