fix(router/affinity): prevent panic caused by nil return in initialization phase#3216
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3216 +/- ##
===========================================
+ Coverage 46.76% 47.92% +1.15%
===========================================
Files 295 463 +168
Lines 17172 33823 +16651
===========================================
+ Hits 8031 16210 +8179
- Misses 8287 16304 +8017
- Partials 854 1309 +455 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
1f6709e to
4a1956d
Compare
4a1956d to
f0f2cd8
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes a panic in the affinity router initialization when the application name is not present in the URL by propagating it from the SubURL. The panic occurred because newApplicationAffinityRouter returns nil when the application name is empty, causing a nil pointer dereference during router chain operations.
Changes:
- Added logic to populate the application name from SubURL to the main URL in NewRouterChain
- Added a mutex to serialize access during the application name population
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
5e7d6e2 to
9b9b75e
Compare
9b9b75e to
cdba5ce
Compare
…ation phase Signed-off-by: Aetherance <inkToAether@gmail.com>
cdba5ce to
794580a
Compare
|



Description
在一些情况下,client 配置 affinity router 时,会因为 nil 而触发段错误
该 bug 只会在配置了 application 模式的 affinity router 上出现,如果配置 service 模式的 affinity router 则不会触发该 bug
配置代码:
client:
server:
bug 原因是当前版本的client应用名未能被正确传递至 router chain。这导致 router chain 在 初始化 affinity router 时,由于获取到空应用名而直接返回 nil。最终造成 nil 被访问而 panic
本 pr 添加了在 router chain 读取应用名的逻辑来修复此 bug
Fixes #3203
Checklist
develop