Skip to content

Fix: exclude RegistryConfig when fast check duplicated equivalent config#16382

Open
dslztx wants to merge 2 commits into
apache:3.3from
dslztx:fix/excludeRegistryConfig2
Open

Fix: exclude RegistryConfig when fast check duplicated equivalent config#16382
dslztx wants to merge 2 commits into
apache:3.3from
dslztx:fix/excludeRegistryConfig2

Conversation

@dslztx

@dslztx dslztx commented Jul 15, 2026

Copy link
Copy Markdown

Fixes #16381

This PR addresses the dubbo load exception which is triggered by incorrect registry config deduplication

…nfig

    if the dubbo consumer xml config is as follow

        <dubbo:registry id="zk1" protocol="zookeeper"
                        address="${ZK1_ADDRESS:10.47.181.23:2181,10.47.181.24:2181,10.47.181.25:2181}"/>

        <dubbo:registry id="zk2" protocol="zookeeper"
                        address="${ZK2_ADDRESS:10.47.181.20:2181,10.47.181.21:2181,10.47.181.22:2181}"/>

        <dubbo:reference id="app1" interface="com.test.app1"
registry="zk1"/>

        <dubbo:reference id="app2" interface="com.test.app2"
registry="zk2"/>

    in which ZK1_ADDRESS and ZK2_ADDRESS are env variables.

    what is exactly needed is that ZK1_ADDRESS and ZK2_ADDRESS may be the same or different.

    when ZK1_ADDRESS and ZK2_ADDRESS are the same, current implementation will only register zk1 registy config successfully, the zk2 registry config is identified as duplication,then it throws exception `java.lang.IllegalStateException: Registry not found: zk2` when loading app2 reference config

@LI123456mo LI123456mo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@dslztx have gone through the issue and the PR and have really understood what you were trying to fix .Have run the tests alone to connfirm the PR requests fix it worked; maybe you can try add this test and check if it passes the flacky tests?
or running-> mvn spotless:apply

@Test
void testRegistryConfigSameAddressDifferentId() {
    RegistryConfig zk1 = new RegistryConfig();
    zk1.setId("zk1");
    zk1.setProtocol("zookeeper");
    zk1.setAddress("10.47.181.23:2181,10.47.181.24:2181,10.47.181.25:2181");

    RegistryConfig zk2 = new RegistryConfig();
    zk2.setId("zk2");
    zk2.setProtocol("zookeeper");
    zk2.setAddress("10.47.181.23:2181,10.47.181.24:2181,10.47.181.25:2181");

    configManager.addConfig(zk1);
    configManager.addConfig(zk2);

    assertTrue(configManager.getConfig(RegistryConfig.class, "zk1").isPresent());
    assertTrue(configManager.getConfig(RegistryConfig.class, "zk2").isPresent());
}

@zrlw zrlw added the status/waiting-for-feedback Need reporters to triage label Jul 16, 2026
@codecov-commenter

codecov-commenter commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.90%. Comparing base (d0bf5c3) to head (ee2c7a7).

Additional details and impacted files
@@             Coverage Diff              @@
##                3.3   #16382      +/-   ##
============================================
+ Coverage     60.86%   60.90%   +0.04%     
- Complexity    11763    11769       +6     
============================================
  Files          1953     1953              
  Lines         89262    89263       +1     
  Branches      13471    13472       +1     
============================================
+ Hits          54331    54368      +37     
+ Misses        29329    29314      -15     
+ Partials       5602     5581      -21     
Flag Coverage Δ
integration-tests-java21 32.07% <100.00%> (-0.03%) ⬇️
integration-tests-java8 32.22% <100.00%> (+0.06%) ⬆️
samples-tests-java21 32.17% <100.00%> (+0.01%) ⬆️
samples-tests-java8 29.73% <100.00%> (-0.07%) ⬇️
unit-tests-java11 59.14% <100.00%> (+0.02%) ⬆️
unit-tests-java17 58.60% <100.00%> (+<0.01%) ⬆️
unit-tests-java21 58.55% <100.00%> (-0.05%) ⬇️
unit-tests-java25 58.55% <100.00%> (+0.01%) ⬆️
unit-tests-java8 59.09% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dslztx

dslztx commented Jul 16, 2026

Copy link
Copy Markdown
Author

@LI123456mo I have added a unit test and reformatted the code according to what you said.

@LI123456mo LI123456mo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM @zrlw

@zrlw zrlw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@zrlw zrlw added status/wait for another approve type/bug Bugs to being fixed and removed status/waiting-for-feedback Need reporters to triage labels Jul 17, 2026
@zrlw
zrlw requested a review from Copilot July 17, 2026 03:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a Dubbo configuration-loading failure caused by RegistryConfig being incorrectly treated as a duplicated equivalent config (because AbstractConfig.equals() intentionally ignores id). The change ensures multiple registry configs with the same address but different IDs can coexist, matching how XML registry="..." references resolve configs by id.

Changes:

  • Skip the “equivalent config” fast-duplicate check for RegistryConfig to avoid dropping a second registry that differs only by id.
  • Skip the value-based duplicated-config lookup for RegistryConfig inside addIfAbsent, ensuring both registry IDs remain registered.
  • Add a regression test asserting two RegistryConfig entries with the same address but different IDs are both present.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
dubbo-common/src/main/java/org/apache/dubbo/config/context/AbstractConfigManager.java Adjusts deduplication logic so RegistryConfig instances aren’t collapsed by value-equality (which ignores id).
dubbo-common/src/test/java/org/apache/dubbo/config/context/AbstractConfigManagerTest.java Adds a regression test covering same-address/different-id registry configs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +216 to 222
if (!(config instanceof RegistryConfig)) {
// find by value
Optional<C> prevConfig = findDuplicatedConfig(configsMap, config);
if (prevConfig.isPresent()) {
return prevConfig.get();
}
}
Comment on lines +19 to +41
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.context.ConfigManagerTest.TestPreferSerializationProvider;
import org.apache.dubbo.rpc.model.ApplicationModel;
import org.apache.dubbo.rpc.model.FrameworkModel;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertTrue;

class AbstractConfigManagerTest {

private ConfigManager configManager;
private ModuleConfigManager moduleConfigManager;

@BeforeEach
public void init() {
ApplicationModel.defaultModel().destroy();
ApplicationModel applicationModel = ApplicationModel.defaultModel();
configManager = applicationModel.getApplicationConfigManager();
moduleConfigManager = applicationModel.getDefaultModule().getConfigManager();
FrameworkModel.defaultModel().getBeanFactory().registerBean(TestPreferSerializationProvider.class);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] removing the so-called registry config duplication leads to exception

5 participants