This is an automated email from the ASF dual-hosted git repository. zhangliang 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 f8dcb5db662 Refactor EncryptTableChangedProcessor and ReadwriteSplittingDataSourceChangedProcessor (#33490) f8dcb5db662 is described below commit f8dcb5db6624053f433368d6c46c80599c04b825 Author: Liang Zhang <zhangli...@apache.org> AuthorDate: Fri Nov 1 11:39:57 2024 +0800 Refactor EncryptTableChangedProcessor and ReadwriteSplittingDataSourceChangedProcessor (#33490) --- .../encrypt/rule/changed/EncryptTableChangedProcessor.java | 7 +------ .../changed/ReadwriteSplittingDataSourceChangedProcessor.java | 9 ++++----- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/changed/EncryptTableChangedProcessor.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/changed/EncryptTableChangedProcessor.java index e8570540e82..57b652ab7ce 100644 --- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/changed/EncryptTableChangedProcessor.java +++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/changed/EncryptTableChangedProcessor.java @@ -45,15 +45,10 @@ public final class EncryptTableChangedProcessor implements RuleItemConfiguration @Override public EncryptRuleConfiguration findRuleConfiguration(final ShardingSphereDatabase database) { - return database.getRuleMetaData().findSingleRule(EncryptRule.class) - .map(optional -> getEncryptRuleConfiguration(optional.getConfiguration())) + return database.getRuleMetaData().findSingleRule(EncryptRule.class).map(EncryptRule::getConfiguration) .orElseGet(() -> new EncryptRuleConfiguration(new LinkedList<>(), new LinkedHashMap<>())); } - private EncryptRuleConfiguration getEncryptRuleConfiguration(final EncryptRuleConfiguration config) { - return null == config.getTables() ? new EncryptRuleConfiguration(new LinkedList<>(), config.getEncryptors()) : config; - } - @Override public void changeRuleItemConfiguration(final AlterRuleItemEvent event, final EncryptRuleConfiguration currentRuleConfig, final EncryptTableRuleConfiguration toBeChangedItemConfig) { // TODO refactor DistSQL to only persist config diff --git a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/changed/ReadwriteSplittingDataSourceChangedProcessor.java b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/changed/ReadwriteSplittingDataSourceChangedProcessor.java index a159c04261e..da075167496 100644 --- a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/changed/ReadwriteSplittingDataSourceChangedProcessor.java +++ b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/changed/ReadwriteSplittingDataSourceChangedProcessor.java @@ -19,22 +19,21 @@ package org.apache.shardingsphere.readwritesplitting.rule.changed; import com.google.common.base.Strings; import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase; +import org.apache.shardingsphere.infra.util.yaml.YamlEngine; import org.apache.shardingsphere.mode.event.dispatch.rule.alter.AlterNamedRuleItemEvent; import org.apache.shardingsphere.mode.event.dispatch.rule.alter.AlterRuleItemEvent; import org.apache.shardingsphere.mode.event.dispatch.rule.drop.DropNamedRuleItemEvent; import org.apache.shardingsphere.mode.event.dispatch.rule.drop.DropRuleItemEvent; -import org.apache.shardingsphere.infra.util.yaml.YamlEngine; import org.apache.shardingsphere.mode.spi.RuleItemConfigurationChangedProcessor; import org.apache.shardingsphere.readwritesplitting.config.ReadwriteSplittingRuleConfiguration; import org.apache.shardingsphere.readwritesplitting.config.rule.ReadwriteSplittingDataSourceGroupRuleConfiguration; -import org.apache.shardingsphere.readwritesplitting.transaction.TransactionalReadQueryStrategy; import org.apache.shardingsphere.readwritesplitting.metadata.nodepath.ReadwriteSplittingRuleNodePathProvider; import org.apache.shardingsphere.readwritesplitting.rule.ReadwriteSplittingRule; +import org.apache.shardingsphere.readwritesplitting.transaction.TransactionalReadQueryStrategy; import org.apache.shardingsphere.readwritesplitting.yaml.config.rule.YamlReadwriteSplittingDataSourceGroupRuleConfiguration; import java.util.LinkedHashMap; import java.util.LinkedList; -import java.util.Optional; /** * Readwrite-splitting data source changed processor. @@ -58,8 +57,8 @@ public final class ReadwriteSplittingDataSourceChangedProcessor @Override public ReadwriteSplittingRuleConfiguration findRuleConfiguration(final ShardingSphereDatabase database) { - Optional<ReadwriteSplittingRule> rule = database.getRuleMetaData().findSingleRule(ReadwriteSplittingRule.class); - return rule.map(ReadwriteSplittingRule::getConfiguration).orElseGet(() -> new ReadwriteSplittingRuleConfiguration(new LinkedList<>(), new LinkedHashMap<>())); + return database.getRuleMetaData().findSingleRule(ReadwriteSplittingRule.class).map(ReadwriteSplittingRule::getConfiguration) + .orElseGet(() -> new ReadwriteSplittingRuleConfiguration(new LinkedList<>(), new LinkedHashMap<>())); } @Override