This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 7cb8995 Fixes drop single rule exception (#10617)
7cb8995 is described below
commit 7cb8995672e68b579191b41f3a89728bc7a143b2
Author: Haoran Meng <[email protected]>
AuthorDate: Wed Jun 2 11:06:01 2021 +0800
Fixes drop single rule exception (#10617)
---
.../metadata/watcher/MetaDataChangedWatcher.java | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/metadata/watcher/MetaDataChangedWatcher.java
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/metadata/watcher/MetaDataChangedWatcher.java
index d817b3a..d4fd945 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/metadata/watcher/MetaDataChangedWatcher.java
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/metadata/watcher/MetaDataChangedWatcher.java
@@ -17,18 +17,17 @@
package org.apache.shardingsphere.governance.core.registry.metadata.watcher;
-import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
-import org.apache.shardingsphere.governance.core.registry.cache.CacheNode;
-import
org.apache.shardingsphere.governance.core.registry.config.service.node.SchemaMetadataNode;
-import org.apache.shardingsphere.governance.core.registry.GovernanceWatcher;
import org.apache.shardingsphere.governance.core.registry.GovernanceEvent;
+import org.apache.shardingsphere.governance.core.registry.GovernanceWatcher;
+import org.apache.shardingsphere.governance.core.registry.cache.CacheNode;
import
org.apache.shardingsphere.governance.core.registry.config.event.datasource.DataSourceAlteredEvent;
-import
org.apache.shardingsphere.governance.core.registry.metadata.event.SchemaAddedEvent;
-import
org.apache.shardingsphere.governance.core.registry.metadata.event.SchemaDeletedEvent;
import
org.apache.shardingsphere.governance.core.registry.config.event.rule.RuleConfigurationCachedEvent;
import
org.apache.shardingsphere.governance.core.registry.config.event.rule.RuleConfigurationsChangedEvent;
import
org.apache.shardingsphere.governance.core.registry.config.event.schema.SchemaChangedEvent;
+import
org.apache.shardingsphere.governance.core.registry.config.service.node.SchemaMetadataNode;
+import
org.apache.shardingsphere.governance.core.registry.metadata.event.SchemaAddedEvent;
+import
org.apache.shardingsphere.governance.core.registry.metadata.event.SchemaDeletedEvent;
import org.apache.shardingsphere.governance.core.yaml.schema.pojo.YamlSchema;
import
org.apache.shardingsphere.governance.core.yaml.schema.swapper.SchemaYamlSwapper;
import
org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent;
@@ -45,6 +44,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
+import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
@@ -131,11 +131,11 @@ public final class MetaDataChangedWatcher implements
GovernanceWatcher<Governanc
private GovernanceEvent createRuleChangedEvent(final String schemaName,
final DataChangedEvent event) {
return new RuleConfigurationsChangedEvent(schemaName,
getRuleConfigurations(event.getValue()));
}
-
+
@SuppressWarnings("unchecked")
private Collection<RuleConfiguration> getRuleConfigurations(final String
yamlContent) {
- Collection<YamlRuleConfiguration> rules =
YamlEngine.unmarshal(yamlContent, Collection.class);
- Preconditions.checkState(!rules.isEmpty(), "No available rule to load
for governance.");
+ Collection<YamlRuleConfiguration> rules =
Strings.isNullOrEmpty(yamlContent)
+ ? new LinkedList<>() : YamlEngine.unmarshal(yamlContent,
Collection.class);
return new
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(rules);
}