You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by me...@apache.org on 2021/01/08 08:49:57 UTC

[shardingsphere] branch master updated: fix drop replica_query rule (#8953)

This is an automated email from the ASF dual-hosted git repository.

menghaoran 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 0c2dafa  fix drop replica_query rule (#8953)
0c2dafa is described below

commit 0c2dafa37e0a32321c6e111738d6435f40159180
Author: JingShang Lu <lu...@apache.org>
AuthorDate: Fri Jan 8 16:49:27 2021 +0800

    fix drop replica_query rule (#8953)
---
 .../text/distsql/rdl/impl/DropReplicaQueryRuleBackendHandler.java   | 6 +++++-
 .../backend/text/distsql/rdl/impl/DropResourceBackendHandler.java   | 2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/DropReplicaQueryRuleBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/DropReplicaQueryRuleBackendHandler.java
index 0ca191c..f92251f 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/DropReplicaQueryRuleBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/DropReplicaQueryRuleBackendHandler.java
@@ -75,7 +75,11 @@ public final class DropReplicaQueryRuleBackendHandler extends SchemaRequiredBack
         for (String each : ruleNames) {
             yamlConfig.getDataSources().remove(each);
         }
-        return new YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(Collections.singleton(yamlConfig));
+        if (yamlConfig.getDataSources().isEmpty()) {
+            return new YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(Collections.EMPTY_LIST);
+        } else {
+            return new YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(Collections.singleton(yamlConfig));
+        }
     }
     
     private void post(final String schemaName, final Collection<RuleConfiguration> rules) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/DropResourceBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/DropResourceBackendHandler.java
index be37219..657c2d3 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/DropResourceBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/DropResourceBackendHandler.java
@@ -85,7 +85,7 @@ public final class DropResourceBackendHandler extends SchemaRequiredBackendHandl
             }
         }
         if (!conflictResources.isEmpty()) {
-            throw new ResourceInUsedException(notExistedResourceNames);
+            throw new ResourceInUsedException(conflictResources);
         }
     }