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

jiangmaolin 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 e9e5b9ea2b4 Refactor GlobalRuleDefinitionExecuteEngine, avoid changing 
local rule config before persisting (#34238)
e9e5b9ea2b4 is described below

commit e9e5b9ea2b4036f5c861d0076c9ba84305d01be6
Author: Raigor <[email protected]>
AuthorDate: Fri Jan 3 14:05:12 2025 +0800

    Refactor GlobalRuleDefinitionExecuteEngine, avoid changing local rule 
config before persisting (#34238)
---
 .../engine/global/GlobalRuleDefinitionExecuteEngine.java    | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/engine/global/GlobalRuleDefinitionExecuteEngine.java
 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/engine/global/GlobalRuleDefinitionExecuteEngine.java
index 6fc255cbefe..0d88bc9c859 100644
--- 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/engine/global/GlobalRuleDefinitionExecuteEngine.java
+++ 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/update/rdl/rule/engine/global/GlobalRuleDefinitionExecuteEngine.java
@@ -20,12 +20,10 @@ package 
org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.engine.
 import lombok.RequiredArgsConstructor;
 import 
org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.spi.global.GlobalRuleDefinitionExecutor;
 import 
org.apache.shardingsphere.distsql.statement.rdl.rule.global.GlobalRuleDefinitionStatement;
-import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
 import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 
 import java.sql.SQLException;
-import java.util.Collection;
 
 /**
  * Global rule definition execute engine.
@@ -50,15 +48,6 @@ public final class GlobalRuleDefinitionExecuteEngine {
         ShardingSphereRule rule = 
contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getSingleRule(executor.getRuleClass());
         executor.setRule(rule);
         executor.checkBeforeUpdate(sqlStatement);
-        
contextManager.getPersistServiceFacade().getMetaDataManagerPersistService().alterGlobalRuleConfiguration(processUpdate(sqlStatement,
 rule));
-    }
-    
-    @SuppressWarnings("unchecked")
-    private RuleConfiguration processUpdate(final 
GlobalRuleDefinitionStatement sqlStatement, final ShardingSphereRule rule) {
-        RuleConfiguration result = 
executor.buildToBeAlteredRuleConfiguration(sqlStatement);
-        Collection<RuleConfiguration> ruleConfigs = 
contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getConfigurations();
-        ruleConfigs.remove(rule.getConfiguration());
-        ruleConfigs.add(result);
-        return result;
+        
contextManager.getPersistServiceFacade().getMetaDataManagerPersistService().alterGlobalRuleConfiguration(executor.buildToBeAlteredRuleConfiguration(sqlStatement));
     }
 }

Reply via email to