diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/AbstractConfiguratorListener.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/AbstractConfiguratorListener.java index 8b0b43fad9d..6770e653dff 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/AbstractConfiguratorListener.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/AbstractConfiguratorListener.java @@ -43,7 +43,7 @@ protected final void initWith(String key) { dynamicConfiguration.addListener(key, this); String rawConfig = dynamicConfiguration.getConfig(key); if (!StringUtils.isEmpty(rawConfig)) { - process(new ConfigChangeEvent(key, rawConfig)); + genConfiguratorsFromRawRule(rawConfig); } } @@ -57,13 +57,7 @@ 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; } } @@ -71,6 +65,20 @@ public void process(ConfigChangeEvent event) { 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 getConfigurators() {