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/04/06 15:31:02 UTC

[shardingsphere] branch master updated: Fixes #9916, enhance verification for ShardingStrategyFactory (#9952)

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 4fd1760  Fixes #9916, enhance verification for ShardingStrategyFactory (#9952)
4fd1760 is described below

commit 4fd176033d02367fc0e331c9677374f6ebd18dc5
Author: Raigor <ra...@gmail.com>
AuthorDate: Tue Apr 6 23:30:31 2021 +0800

    Fixes #9916, enhance verification for ShardingStrategyFactory (#9952)
    
    Fixes #9916
---
 .../sharding/route/strategy/ShardingStrategyFactory.java           | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/strategy/ShardingStrategyFactory.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/strategy/ShardingStrategyFactory.java
index 3d629fb..ff12132 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/strategy/ShardingStrategyFactory.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/strategy/ShardingStrategyFactory.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.sharding.route.strategy;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import org.apache.shardingsphere.sharding.api.config.strategy.sharding.ComplexShardingStrategyConfiguration;
+import org.apache.shardingsphere.sharding.api.config.strategy.sharding.HintShardingStrategyConfiguration;
 import org.apache.shardingsphere.sharding.api.config.strategy.sharding.ShardingStrategyConfiguration;
 import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
 import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingAlgorithm;
@@ -45,13 +46,13 @@ public final class ShardingStrategyFactory {
      * @return sharding strategy instance
      */
     public static ShardingStrategy newInstance(final ShardingStrategyConfiguration shardingStrategyConfig, final ShardingAlgorithm shardingAlgorithm) {
-        if (shardingAlgorithm instanceof StandardShardingAlgorithm) {
+        if (shardingStrategyConfig instanceof StandardShardingStrategyConfiguration && shardingAlgorithm instanceof StandardShardingAlgorithm) {
             return new StandardShardingStrategy(((StandardShardingStrategyConfiguration) shardingStrategyConfig).getShardingColumn(), (StandardShardingAlgorithm) shardingAlgorithm);
         }
-        if (shardingAlgorithm instanceof ComplexKeysShardingAlgorithm) {
+        if (shardingStrategyConfig instanceof ComplexShardingStrategyConfiguration && shardingAlgorithm instanceof ComplexKeysShardingAlgorithm) {
             return new ComplexShardingStrategy(((ComplexShardingStrategyConfiguration) shardingStrategyConfig).getShardingColumns(), (ComplexKeysShardingAlgorithm) shardingAlgorithm);
         }
-        if (shardingAlgorithm instanceof HintShardingAlgorithm) {
+        if (shardingStrategyConfig instanceof HintShardingStrategyConfiguration && shardingAlgorithm instanceof HintShardingAlgorithm) {
             return new HintShardingStrategy((HintShardingAlgorithm) shardingAlgorithm);
         }
         return new NoneShardingStrategy();