Skip to content

refactor(AbstractCluster): 调整更新提供者的顺序#1566

Open
sunhailin-Leo wants to merge 1 commit into
masterfrom
fix/issue_1490
Open

refactor(AbstractCluster): 调整更新提供者的顺序#1566
sunhailin-Leo wants to merge 1 commit into
masterfrom
fix/issue_1490

Conversation

@sunhailin-Leo

Copy link
Copy Markdown
Collaborator

此提交调整了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.

此提交调整了`AbstractCluster`类中更新所有提供者的顺序,先更新连接持有者再更新地址持有者。
Copilot AI review requested due to automatic review settings June 16, 2026 16:10
@sofastack-cla sofastack-cla Bot added cla:yes CLA is ok size/L labels Jun 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

关于 AddressHolder 和 ConnectionHolder 更新提供者列表顺序的疑问

2 participants