You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2021/09/01 03:37:37 UTC
[shardingsphere] branch master updated: optimize the code (#12141)
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 745eb37 optimize the code (#12141)
745eb37 is described below
commit 745eb3724a647ae72f6ca7afcf073a12866be821
Author: zhaojinchao <33...@users.noreply.github.com>
AuthorDate: Wed Sep 1 11:37:00 2021 +0800
optimize the code (#12141)
---
.../infra/yaml/config/swapper/mode/ModeConfigurationYamlSwapper.java | 3 ---
.../shardingsphere/spring/boot/ShardingSphereAutoConfiguration.java | 2 +-
.../boot/governance/ShardingSphereGovernanceAutoConfiguration.java | 5 +----
3 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/mode/ModeConfigurationYamlSwapper.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/mode/ModeConfigurationYamlSwapper.java
index e70f8a9..afc3efd 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/mode/ModeConfigurationYamlSwapper.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/mode/ModeConfigurationYamlSwapper.java
@@ -40,9 +40,6 @@ public final class ModeConfigurationYamlSwapper implements YamlConfigurationSwap
@Override
public ModeConfiguration swapToObject(final YamlModeConfiguration yamlConfig) {
- if (null == yamlConfig) {
- return null;
- }
PersistRepositoryConfiguration repositoryConfig = null == yamlConfig.getRepository()
? null : new PersistRepositoryConfigurationYamlSwapperEngine().swapToObject(yamlConfig.getType(), yamlConfig.getRepository());
return new ModeConfiguration(yamlConfig.getType(), repositoryConfig, yamlConfig.isOverwrite());
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/ShardingSphereAutoConfiguration.java b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/ShardingSphereAutoConfiguration.java
index c66ef8c..c04aa11 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/ShardingSphereAutoConfiguration.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/ShardingSphereAutoConfiguration.java
@@ -72,7 +72,7 @@ public class ShardingSphereAutoConfiguration implements EnvironmentAware {
*/
@Bean
public ModeConfiguration modeConfiguration() {
- return new ModeConfigurationYamlSwapper().swapToObject(props.getMode());
+ return null == props.getMode() ? null : new ModeConfigurationYamlSwapper().swapToObject(props.getMode());
}
/**
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/governance/ShardingSphereGovernanceAutoConfiguration.java b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/governance/ShardingSphereGovernanceAutoConfi [...]
index 615d603..18cf857 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/governance/ShardingSphereGovernanceAutoConfiguration.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/governance/ShardingSphereGovernanceAutoConfiguration.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.spring.boot.governance;
-import com.google.common.base.Preconditions;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
@@ -47,7 +46,6 @@ import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.Objects;
import java.util.Optional;
/**
@@ -74,8 +72,7 @@ public class ShardingSphereGovernanceAutoConfiguration implements EnvironmentAwa
*/
@Bean
public ModeConfiguration modeConfiguration() {
- Preconditions.checkState(Objects.nonNull(root.getMode()), "The mode configuration is invalid, please configure mode");
- return new ModeConfigurationYamlSwapper().swapToObject(root.getMode());
+ return null == root.getMode() ? null : new ModeConfigurationYamlSwapper().swapToObject(root.getMode());
}
/**