Skip to content

Commit 4ef74fa

Browse files
chickenljralf0131
authored andcommitted
[Dubbo-3669] Only parse rules on init, does not override. (#3685)
1 parent 1798fed commit 4ef74fa

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/AbstractConfiguratorListener.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected final void initWith(String key) {
4444
dynamicConfiguration.addListener(key, this);
4545
String rawConfig = dynamicConfiguration.getConfig(key, CommonConstants.DUBBO);
4646
if (!StringUtils.isEmpty(rawConfig)) {
47-
process(new ConfigChangeEvent(key, rawConfig));
47+
genConfiguratorsFromRawRule(rawConfig);
4848
}
4949
}
5050

@@ -58,20 +58,28 @@ public void process(ConfigChangeEvent event) {
5858
if (event.getChangeType().equals(ConfigChangeType.DELETED)) {
5959
configurators.clear();
6060
} else {
61-
try {
62-
// parseConfigurators will recognize app/service config automatically.
63-
configurators = Configurator.toConfigurators(ConfigParser.parseConfigurators(event.getValue()))
64-
.orElse(configurators);
65-
} catch (Exception e) {
66-
logger.error("Failed to parse raw dynamic config and it will not take effect, the raw config is: " +
67-
event.getValue(), e);
61+
if (!genConfiguratorsFromRawRule(event.getValue())) {
6862
return;
6963
}
7064
}
7165

7266
notifyOverrides();
7367
}
7468

69+
private boolean genConfiguratorsFromRawRule(String rawConfig) {
70+
boolean parseSuccess = true;
71+
try {
72+
// parseConfigurators will recognize app/service config automatically.
73+
configurators = Configurator.toConfigurators(ConfigParser.parseConfigurators(rawConfig))
74+
.orElse(configurators);
75+
} catch (Exception e) {
76+
logger.error("Failed to parse raw dynamic config and it will not take effect, the raw config is: " +
77+
rawConfig, e);
78+
parseSuccess = false;
79+
}
80+
return parseSuccess;
81+
}
82+
7583
protected abstract void notifyOverrides();
7684

7785
public List<Configurator> getConfigurators() {

0 commit comments

Comments
 (0)