This is an automated email from the ASF dual-hosted git repository. liujun pushed a commit to branch dev-metadata in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git
commit 912498ab0830f9c7ae232fce58ed392489080ecc Author: ken.lj <[email protected]> AuthorDate: Tue Nov 20 14:35:17 2018 +0800 empty rule protection: "" should not be treated as delete. --- .../configcenter/support/apollo/ApolloDynamicConfiguration.java | 6 +++++- .../support/archaius/ArchaiusDynamicConfiguration.java | 9 ++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/dubbo-configcenter/dubbo-configcenter-apollo/src/main/java/org/apache/dubbo/configcenter/support/apollo/ApolloDynamicConfiguration.java b/dubbo-configcenter/dubbo-configcenter-apollo/src/main/java/org/apache/dubbo/configcenter/support/apollo/ApolloDynamicConfiguration.java index ad16d50..f5f2cc0 100644 --- a/dubbo-configcenter/dubbo-configcenter-apollo/src/main/java/org/apache/dubbo/configcenter/support/apollo/ApolloDynamicConfiguration.java +++ b/dubbo-configcenter/dubbo-configcenter-apollo/src/main/java/org/apache/dubbo/configcenter/support/apollo/ApolloDynamicConfiguration.java @@ -133,7 +133,7 @@ public class ApolloDynamicConfiguration extends AbstractDynamicConfiguration<Con } public ConfigChangeType getChangeType(ConfigChange change) { - if (change.getChangeType() == PropertyChangeType.DELETED || StringUtils.isEmpty(change.getNewValue())) { + if (change.getChangeType() == PropertyChangeType.DELETED) { return ConfigChangeType.DELETED; } return ConfigChangeType.MODIFIED; @@ -156,6 +156,10 @@ public class ApolloDynamicConfiguration extends AbstractDynamicConfiguration<Con public void onChange(ConfigChangeEvent changeEvent) { for (String key : changeEvent.changedKeys()) { ConfigChange change = changeEvent.getChange(key); + if (StringUtils.isEmpty(change.getNewValue())) { + logger.warn("We received an empty rule for " + key + ", the current working rule is " + change.getOldValue() + ", the empty rule will not take effect."); + return; + } // TODO Maybe we no longer need to identify the type of change. Because there's no scenario that a callback will subscribe for both configurators and routers if (change.getPropertyName().endsWith(Constants.CONFIGURATORS_SUFFIX)) { listener.process(new org.apache.dubbo.configcenter.ConfigChangeEvent(key, change.getNewValue(), ConfigType.CONFIGURATORS, getChangeType(change))); diff --git a/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/archaius/ArchaiusDynamicConfiguration.java b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/archaius/ArchaiusDynamicConfiguration.java index 883339f..014958d 100644 --- a/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/archaius/ArchaiusDynamicConfiguration.java +++ b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/archaius/ArchaiusDynamicConfiguration.java @@ -22,6 +22,8 @@ import com.netflix.config.DynamicStringProperty; import com.netflix.config.DynamicWatchedConfiguration; import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.logger.Logger; +import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.utils.StringUtils; import org.apache.dubbo.configcenter.AbstractDynamicConfiguration; import org.apache.dubbo.configcenter.ConfigChangeEvent; @@ -34,6 +36,7 @@ import org.apache.dubbo.configcenter.support.archaius.sources.ZooKeeperConfigura * Archaius supports various sources and it's extensiable: JDBC, ZK, Properties, ..., so should we make it extensiable? */ public class ArchaiusDynamicConfiguration extends AbstractDynamicConfiguration<Runnable> { + private static final Logger logger = LoggerFactory.getLogger(ArchaiusDynamicConfiguration.class); public ArchaiusDynamicConfiguration() { } @@ -142,10 +145,14 @@ public class ArchaiusDynamicConfiguration extends AbstractDynamicConfiguration<R .getStringProperty(key, null); String newValue = prop.get(); ConfigChangeEvent event = new ConfigChangeEvent(key, newValue, type); - if (StringUtils.isEmpty(newValue)) { + if (newValue == null) { event.setChangeType(ConfigChangeType.DELETED); listener.process(event); } else { + if (newValue.equals("")) { + logger.warn("We received an empty rule for " + key + ", the current working rule is unknown, the empty rule will not take effect."); + return; + } event.setChangeType(ConfigChangeType.MODIFIED); listener.process(event); }
