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 2024/06/24 15:53:06 UTC
(shardingsphere) branch master updated: Fix sonar issue of DropDefaultShardingStrategyExecutor (#31831)
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 68839608778 Fix sonar issue of DropDefaultShardingStrategyExecutor (#31831)
68839608778 is described below
commit 688396087783d206dc1f441df3c24fb87a9ffe7f
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Mon Jun 24 23:52:59 2024 +0800
Fix sonar issue of DropDefaultShardingStrategyExecutor (#31831)
---
.../distsql/handler/update/DropDefaultShardingStrategyExecutor.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropDefaultShardingStrategyExecutor.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropDefaultShardingStrategyExecutor.java
index 14eb116ddb2..476fa0c0ade 100644
--- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropDefaultShardingStrategyExecutor.java
+++ b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropDefaultShardingStrategyExecutor.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.sharding.distsql.handler.update;
import lombok.Setter;
import org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.spi.database.DatabaseRuleDropExecutor;
import org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
+import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.exception.kernel.metadata.rule.MissingRequiredRuleException;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
@@ -49,8 +50,9 @@ public final class DropDefaultShardingStrategyExecutor implements DatabaseRuleDr
}
private void checkExist(final DropDefaultShardingStrategyStatement sqlStatement) {
- getStrategyConfiguration(sqlStatement.getDefaultType())
- .orElseThrow(() -> new MissingRequiredRuleException(String.format("Default sharding %s strategy", sqlStatement.getDefaultType().toLowerCase()), database.getName()));
+ Optional<ShardingStrategyConfiguration> shardingStrategyConfig = getStrategyConfiguration(sqlStatement.getDefaultType());
+ ShardingSpherePreconditions.checkState(shardingStrategyConfig.isPresent(),
+ () -> new MissingRequiredRuleException(String.format("Default sharding %s strategy", sqlStatement.getDefaultType().toLowerCase()), database.getName()));
}
private Optional<ShardingStrategyConfiguration> getStrategyConfiguration(final String type) {