Skip to content

Commit

Permalink
[Dubbo-3669] Only parse rules on init, does not override. (#3685)
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenlj authored and ralf0131 committed May 16, 2019
1 parent 1798fed commit 4ef74fa
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected final void initWith(String key) {
dynamicConfiguration.addListener(key, this);
String rawConfig = dynamicConfiguration.getConfig(key, CommonConstants.DUBBO);
if (!StringUtils.isEmpty(rawConfig)) {
process(new ConfigChangeEvent(key, rawConfig));
genConfiguratorsFromRawRule(rawConfig);
}
}

Expand All @@ -58,20 +58,28 @@ public void process(ConfigChangeEvent event) {
if (event.getChangeType().equals(ConfigChangeType.DELETED)) {
configurators.clear();
} else {
try {
// parseConfigurators will recognize app/service config automatically.
configurators = Configurator.toConfigurators(ConfigParser.parseConfigurators(event.getValue()))
.orElse(configurators);
} catch (Exception e) {
logger.error("Failed to parse raw dynamic config and it will not take effect, the raw config is: " +
event.getValue(), e);
if (!genConfiguratorsFromRawRule(event.getValue())) {
return;
}
}

notifyOverrides();
}

private boolean genConfiguratorsFromRawRule(String rawConfig) {
boolean parseSuccess = true;
try {
// parseConfigurators will recognize app/service config automatically.
configurators = Configurator.toConfigurators(ConfigParser.parseConfigurators(rawConfig))
.orElse(configurators);
} catch (Exception e) {
logger.error("Failed to parse raw dynamic config and it will not take effect, the raw config is: " +
rawConfig, e);
parseSuccess = false;
}
return parseSuccess;
}

protected abstract void notifyOverrides();

public List<Configurator> getConfigurators() {
Expand Down

0 comments on commit 4ef74fa

Please sign in to comment.