refactor(AbstractCluster): 调整更新提供者的顺序#1566
Open
sunhailin-Leo wants to merge 1 commit into
Open
Conversation
此提交调整了`AbstractCluster`类中更新所有提供者的顺序,先更新连接持有者再更新地址持有者。
There was a problem hiding this comment.
Pull request overview
该 PR 为了解决 Issue #1490 中“地址列表更新后连接尚未建立导致短暂不可用”的问题,调整了 AbstractCluster.updateAllProviders 中更新提供者的调用顺序,使其先更新 ConnectionHolder 再更新 AddressHolder,并新增了对应的单测来验证顺序。
Changes:
- 调整
AbstractCluster.updateAllProviders(...):先connectionHolder.updateAllProviders,再addressHolder.updateAllProviders - 新增单测验证
updateAllProviders中两者调用顺序
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| core-impl/client/src/main/java/com/alipay/sofa/rpc/client/AbstractCluster.java | 调整 updateAllProviders 内部更新顺序以降低“地址可见但连接未就绪”的窗口期 |
| core-impl/client/src/test/java/com/alipay/sofa/rpc/client/AbstractClusterTest.java | 增加用例验证 updateAllProviders 的调用顺序 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
258
to
260
| connectionHolder.updateAllProviders(providerGroups); | ||
| addressHolder.updateAllProviders(providerGroups); | ||
| } |
Comment on lines
+294
to
+305
| // 通过反射设置 Mock 对象 | ||
| try { | ||
| java.lang.reflect.Field addressHolderField = AbstractCluster.class.getDeclaredField("addressHolder"); | ||
| addressHolderField.setAccessible(true); | ||
| addressHolderField.set(cluster, mockAddressHolder); | ||
|
|
||
| java.lang.reflect.Field connectionHolderField = AbstractCluster.class.getDeclaredField("connectionHolder"); | ||
| connectionHolderField.setAccessible(true); | ||
| connectionHolderField.set(cluster, mockConnectionHolder); | ||
| } catch (Exception e) { | ||
| throw new RuntimeException("Failed to set mock objects", e); | ||
| } |
| providerInfo.setHost("127.0.0.1"); | ||
| providerInfo.setPort(8080); | ||
| providerInfo.setPath("/test"); | ||
| providerInfo.setProtocolType("bolt"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
此提交调整了
AbstractCluster类中更新所有提供者的顺序,先更新连接持有者再更新地址持有者。Motivation:
Explain the context, and why you're making that change.
To make others understand what is the problem you're trying to solve.
Modification:
Describe the idea and modifications you've done.
Result:
Fixes #1490 .
If there is no issue then describe the changes introduced by this PR.