You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/05/08 06:48:26 UTC
[shardingsphere] branch master updated: Refactor TypedSPIRegistry (#17442)
This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 18c953c495a Refactor TypedSPIRegistry (#17442)
18c953c495a is described below
commit 18c953c495aede1622b2e26b4753cfa8c9421dd6
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sun May 8 14:48:19 2022 +0800
Refactor TypedSPIRegistry (#17442)
* Refactor TypedSPIRegistry
* Refactor TypedSPIRegistry
* Refactor TypedSPIRegistry
* Refactor TypedSPIRegistry
* Refactor TypedSPIRegistry
---
.../DatabaseDiscoveryProviderAlgorithmFactory.java | 2 +-
...iscoveryProviderAlgorithmStatementUpdaterTest.java | 2 +-
.../DatabaseDiscoverySpringNamespaceTest.java | 4 ++--
.../encrypt/factory/EncryptAlgorithmFactory.java | 2 +-
.../encrypt/sm/algorithm/SM4EncryptAlgorithm.java | 2 +-
.../factory/ReplicaLoadBalanceAlgorithmFactory.java | 2 +-
.../WeightReplicaLoadBalanceAlgorithm.java | 6 +++---
.../boot/ReadwriteSplittingSpringBootStarterTest.java | 4 ++--
.../shadow/factory/ShadowAlgorithmFactory.java | 2 +-
.../column/ColumnValueMatchShadowAlgorithm.java | 2 +-
.../shardingsphere/shadow/rule/ShadowTableRule.java | 2 +-
.../converter/ShadowRuleStatementConverterTest.java | 2 +-
.../boot/PropertiesShadowSpringBootStarterTest.java | 11 ++++++-----
.../boot/YmlShadowDefaultSpringBootStarterTest.java | 4 ++--
.../spring/boot/YmlShadowSpringBootStarterTest.java | 16 ++++++++--------
.../namespace/ShadowAlgorithmSpringNamespaceTest.java | 17 +++++++++--------
.../ShadowDefaultAlgorithmSpringNamespaceTest.java | 4 ++--
.../sharding/factory/KeyGenerateAlgorithmFactory.java | 2 +-
.../sharding/factory/ShardingAlgorithmFactory.java | 2 +-
.../sharding/mod/HashModShardingAlgorithm.java | 2 +-
.../algorithm/sharding/mod/ModShardingAlgorithm.java | 2 +-
.../range/VolumeBasedRangeShardingAlgorithm.java | 6 +++---
.../converter/ShardingRuleStatementConverterTest.java | 4 ++--
.../algorithm/keygen/CosIdKeyGenerateAlgorithm.java | 2 +-
.../keygen/CosIdSnowflakeKeyGenerateAlgorithm.java | 2 +-
.../AbstractCosIdIntervalShardingAlgorithm.java | 4 ++--
.../CosIdSnowflakeIntervalShardingAlgorithm.java | 2 +-
.../sharding/mod/CosIdModShardingAlgorithm.java | 2 +-
.../AbstractAlgorithmProvidedBeanRegistry.java | 14 +++++++++++++-
.../detect/JobCompletionDetectAlgorithmFactory.java | 2 +-
.../ingest/channel/PipelineChannelCreatorFactory.java | 2 +-
.../spi/ratelimit/JobRateLimitAlgorithmFactory.java | 2 +-
.../traffic/factory/TrafficAlgorithmFactory.java | 2 +-
.../factory/TrafficLoadBalanceAlgorithmFactory.java | 2 +-
.../traffic/segment/SQLRegexTrafficAlgorithm.java | 4 ++--
.../mode/manager/ContextManagerTest.java | 2 +-
.../backend/config/ProxyConfigurationLoaderTest.java | 4 ++--
.../ral/common/updatable/SetVariableExecutorTest.java | 3 +++
.../spi/type/typed/TypedSPIRegistry.java | 19 +++++++++++--------
39 files changed, 95 insertions(+), 75 deletions(-)
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/factory/DatabaseDiscoveryProviderAlgorithmFactory.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/factory/DatabaseDiscoveryProviderAlgorithmFactory.java
index 4d69b52bf02..d31836f6dd6 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/factory/DatabaseDiscoveryProviderAlgorithmFactory.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-api/src/main/java/org/apache/shardingsphere/dbdiscovery/factory/DatabaseDiscoveryProviderAlgorithmFactory.java
@@ -52,6 +52,6 @@ public final class DatabaseDiscoveryProviderAlgorithmFactory {
* @return contains database discovery provider algorithm or not
*/
public static boolean contains(final String databaseDiscoveryProviderAlgorithmType) {
- return TypedSPIRegistry.findRegisteredService(DatabaseDiscoveryProviderAlgorithm.class, databaseDiscoveryProviderAlgorithmType, null).isPresent();
+ return TypedSPIRegistry.findRegisteredService(DatabaseDiscoveryProviderAlgorithm.class, databaseDiscoveryProviderAlgorithmType).isPresent();
}
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryProviderAlgorithmStatementUpdaterTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update [...]
index d1e99ea5c77..9840422e096 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryProviderAlgorithmStatementUpdaterTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/update/AlterDatabaseDiscoveryProviderAlgorithmStatementUpdaterTest.java
@@ -98,6 +98,6 @@ public final class AlterDatabaseDiscoveryProviderAlgorithmStatementUpdaterTest {
updater.updateCurrentRuleConfiguration(currentConfig, databaseDiscoveryRuleConfig);
assertThat(currentConfig.getDiscoveryTypes().size(), is(1));
assertThat(currentConfig.getDiscoveryTypes().get("discovery_type").getType(), is("DISTSQL.FIXTURE"));
- assertThat(currentConfig.getDiscoveryTypes().get("discovery_type").getProps().get("key"), is("value_1"));
+ assertThat(currentConfig.getDiscoveryTypes().get("discovery_type").getProps().getProperty("key"), is("value_1"));
}
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-spring/shardingsphere-db-discovery-spring-namespace/src/test/java/org/apache/shardingsphere/dbdiscovery/spring/namespace/DatabaseDiscoverySpringNamespaceTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-spring/shardingsphere-db-discovery-spring-namespace/src/test/java/org/apache/shardingsphere/dbdiscovery/spring/namespace/DatabaseDiscoverySpringNamespaceTest.java
index d287c3638da..e00ecc16710 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-spring/shardingsphere-db-discovery-spring-namespace/src/test/java/org/apache/shardingsphere/dbdiscovery/spring/namespace/DatabaseDiscoverySpringNamespaceTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-spring/shardingsphere-db-discovery-spring-namespace/src/test/java/org/apache/shardingsphere/dbdiscovery/spring/namespace/DatabaseDiscoverySpringNamespaceTest.java
@@ -51,13 +51,13 @@ public final class DatabaseDiscoverySpringNamespaceTest extends AbstractJUnit4Sp
private void assertDiscoveryTypes(final Map<String, DatabaseDiscoveryProviderAlgorithm> discoveryTypes) {
assertThat(discoveryTypes.size(), is(1));
assertThat(discoveryTypes.get("mgr"), instanceOf(MGRMySQLDatabaseDiscoveryProviderAlgorithm.class));
- assertThat(discoveryTypes.get("mgr").getProps().get("group-name"), is("92504d5b-6dec-11e8-91ea-246e9612aaf1"));
+ assertThat(discoveryTypes.get("mgr").getProps().getProperty("group-name"), is("92504d5b-6dec-11e8-91ea-246e9612aaf1"));
}
private void assertHeartbeats(final Map<String, DatabaseDiscoveryHeartBeatConfiguration> heartbeats) {
assertThat(heartbeats.size(), is(1));
assertThat(heartbeats.get("mgr-heartbeat"), instanceOf(DatabaseDiscoveryHeartBeatConfiguration.class));
- assertThat(heartbeats.get("mgr-heartbeat").getProps().get("keep-alive-cron"), is("0/5 * * * * ?"));
+ assertThat(heartbeats.get("mgr-heartbeat").getProps().getProperty("keep-alive-cron"), is("0/5 * * * * ?"));
}
private void assertDefaultDataSourceRule(final DatabaseDiscoveryDataSourceRuleConfiguration dataSourceRuleConfig) {
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-api/src/main/java/org/apache/shardingsphere/encrypt/factory/EncryptAlgorithmFactory.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-api/src/main/java/org/apache/shardingsphere/encrypt/factory/EncryptAlgorithmFactory.java
index 4dd7c191cdc..b0f60bac128 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-api/src/main/java/org/apache/shardingsphere/encrypt/factory/EncryptAlgorithmFactory.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-api/src/main/java/org/apache/shardingsphere/encrypt/factory/EncryptAlgorithmFactory.java
@@ -54,6 +54,6 @@ public final class EncryptAlgorithmFactory {
* @return contains encrypt algorithm or not
*/
public static boolean contains(final String encryptAlgorithmType) {
- return TypedSPIRegistry.findRegisteredService(EncryptAlgorithm.class, encryptAlgorithmType, null).isPresent();
+ return TypedSPIRegistry.findRegisteredService(EncryptAlgorithm.class, encryptAlgorithmType).isPresent();
}
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-plugin/shardingsphere-encrypt-sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithm.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-plugin/shardingsphere-encrypt-sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithm.java
index e06269a9907..2f5da2d7bc8 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-plugin/shardingsphere-encrypt-sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-plugin/shardingsphere-encrypt-sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithm.java
@@ -108,7 +108,7 @@ public final class SM4EncryptAlgorithm implements EncryptAlgorithm<Object, Strin
private String createSm4Padding(final Properties props) {
Preconditions.checkArgument(props.containsKey(SM4_PADDING), "%s can not be null.", SM4_PADDING);
- String result = String.valueOf(props.get(SM4_PADDING)).toUpperCase().replace("PADDING", "Padding");
+ String result = String.valueOf(props.getProperty(SM4_PADDING)).toUpperCase().replace("PADDING", "Padding");
Preconditions.checkState(PADDINGS.contains(result), "Padding must be either PKCS5Padding or PKCS7Padding.");
return result;
}
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-api/src/main/java/org/apache/shardingsphere/readwritesplitting/factory/ReplicaLoadBalanceAlgorithmFactory.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-api/src/main/java/org/apache/shardingsphere/readwritesplitting/factory/ReplicaLoadBalanceAlgorithmFactory.java
index 39f5054baa6..1c5f703db9e 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-api/src/main/java/org/apache/shardingsphere/readwritesplitting/factory/ReplicaLoadBalanceAlgorithmFactory.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-api/src/main/java/org/apache/shardingsphere/readwritesplitting/factory/ReplicaLoadBalanceAlgorithmFactory.java
@@ -62,6 +62,6 @@ public final class ReplicaLoadBalanceAlgorithmFactory {
* @return contains replica load-balance algorithm or not
*/
public static boolean contains(final String replicaLoadBalanceAlgorithmType) {
- return TypedSPIRegistry.findRegisteredService(ReplicaLoadBalanceAlgorithm.class, replicaLoadBalanceAlgorithmType, null).isPresent();
+ return TypedSPIRegistry.findRegisteredService(ReplicaLoadBalanceAlgorithm.class, replicaLoadBalanceAlgorithmType).isPresent();
}
}
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/WeightReplicaLoadBalanceAlgorithm.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/WeightReplicaLoadBalanceAlgorithm.java
index 9312dc18ee1..d4669fb6112 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/WeightReplicaLoadBalanceAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/WeightReplicaLoadBalanceAlgorithm.java
@@ -95,14 +95,14 @@ public final class WeightReplicaLoadBalanceAlgorithm implements ReplicaLoadBalan
private double getWeightValue(final String readDataSourceName) {
Object weightObject = props.get(readDataSourceName);
- if (weightObject == null) {
+ if (null == weightObject) {
throw new IllegalStateException("Read database access weight is not configured:" + readDataSourceName);
}
double result;
try {
result = Double.parseDouble(weightObject.toString());
- } catch (NumberFormatException e) {
- throw new NumberFormatException("Read database weight configuration error, configuration parameters:" + weightObject.toString());
+ } catch (final NumberFormatException ex) {
+ throw new NumberFormatException("Read database weight configuration error, configuration parameters:" + weightObject);
}
if (Double.isInfinite(result)) {
result = 10000.0D;
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-spring/shardingsphere-readwrite-splitting-spring-boot-starter/src/test/java/org/apache/shardingsphere/readwritesplitting/spring/boot/ReadwriteSplittingSpringBootStarterTest.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-spring/shardingsphere-readwrite-splitting-spring-boot-starter/src/test/java/org/apache/shardingsphere/readwrites [...]
index 4529f90fb06..32e1b3c6293 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-spring/shardingsphere-readwrite-splitting-spring-boot-starter/src/test/java/org/apache/shardingsphere/readwritesplitting/spring/boot/ReadwriteSplittingSpringBootStarterTest.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-spring/shardingsphere-readwrite-splitting-spring-boot-starter/src/test/java/org/apache/shardingsphere/readwritesplitting/spring/boot/ReadwriteSplittingSpringBootStarterTest.java
@@ -57,8 +57,8 @@ public class ReadwriteSplittingSpringBootStarterTest {
ReadwriteSplittingDataSourceRuleConfiguration dataSourceRuleConfig = config.getDataSources().stream().findFirst().get();
assertThat(dataSourceRuleConfig.getName(), is("readwrite_ds"));
assertThat(dataSourceRuleConfig.getType(), is("Static"));
- assertThat(dataSourceRuleConfig.getProps().get("write-data-source-name"), is("write_ds"));
- assertThat(dataSourceRuleConfig.getProps().get("read-data-source-names"), is("read_ds_0,read_ds_1"));
+ assertThat(dataSourceRuleConfig.getProps().getProperty("write-data-source-name"), is("write_ds"));
+ assertThat(dataSourceRuleConfig.getProps().getProperty("read-data-source-names"), is("read_ds_0,read_ds_1"));
assertThat(dataSourceRuleConfig.getLoadBalancerName(), is("random"));
assertTrue(config.getDataSources().contains(dataSourceRuleConfig));
assertThat(config.getLoadBalanceAlgorithms().size(), is(1));
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-api/src/main/java/org/apache/shardingsphere/shadow/factory/ShadowAlgorithmFactory.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-api/src/main/java/org/apache/shardingsphere/shadow/factory/ShadowAlgorithmFactory.java
index e74b0fbbd0e..8ff99525715 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-api/src/main/java/org/apache/shardingsphere/shadow/factory/ShadowAlgorithmFactory.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-api/src/main/java/org/apache/shardingsphere/shadow/factory/ShadowAlgorithmFactory.java
@@ -52,6 +52,6 @@ public final class ShadowAlgorithmFactory {
* @return contains shadow algorithm or not
*/
public static boolean contains(final String shadowAlgorithmType) {
- return TypedSPIRegistry.findRegisteredService(ShadowAlgorithm.class, shadowAlgorithmType, null).isPresent();
+ return TypedSPIRegistry.findRegisteredService(ShadowAlgorithm.class, shadowAlgorithmType).isPresent();
}
}
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchShadowAlgorithm.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchShadowAlgorithm.java
index 07e4e00e840..51886f9caa4 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchShadowAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchShadowAlgorithm.java
@@ -43,7 +43,7 @@ public final class ColumnValueMatchShadowAlgorithm extends AbstractColumnMatchSh
}
private String getShadowValue(final Properties props) {
- String result = String.valueOf(props.get(VALUE_PROPS_KEY));
+ String result = props.getProperty(VALUE_PROPS_KEY);
Preconditions.checkNotNull(result, "Column value match shadow algorithm value cannot be null.");
return result;
}
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/rule/ShadowTableRule.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/rule/ShadowTableRule.java
index 6a9952e725d..3e11285f045 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/rule/ShadowTableRule.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/rule/ShadowTableRule.java
@@ -60,7 +60,7 @@ public final class ShadowTableRule {
shadowAlgorithmNames.forEach(each -> {
ShadowAlgorithm shadowAlgorithm = shadowAlgorithms.get(each);
if (shadowAlgorithm instanceof ColumnShadowAlgorithm) {
- ShadowOperationType.contains(shadowAlgorithm.getProps().get("operation").toString()).ifPresent(optional -> initShadowAlgorithmNames(result, each, optional));
+ ShadowOperationType.contains(shadowAlgorithm.getProps().getProperty("operation")).ifPresent(optional -> initShadowAlgorithmNames(result, each, optional));
}
});
return result;
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/converter/ShadowRuleStatementConverterTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/converter/ShadowRuleStatementConverterTest.java
index a3755bcc692..b911e6734d8 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/converter/ShadowRuleStatementConverterTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/test/java/org/apache/shardingsphere/shadow/distsql/converter/ShadowRuleStatementConverterTest.java
@@ -39,7 +39,7 @@ public final class ShadowRuleStatementConverterTest {
assertThat(config.getDataSources().get("ruleName").getShadowDataSourceName(), is("shadow"));
assertThat(config.getTables().size(), is(1));
assertThat(config.getShadowAlgorithms().size(), is(1));
- assertThat(config.getShadowAlgorithms().get("algorithmsName").getProps().get("foo"), is("bar"));
+ assertThat(config.getShadowAlgorithms().get("algorithmsName").getProps().getProperty("foo"), is("bar"));
}
private ShadowRuleSegment createTableRuleSegment() {
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/PropertiesShadowSpringBootStarterTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/PropertiesShadowSpringBootStarterTest.java
index 6429609f8a6..f8abb4a12f2 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/PropertiesShadowSpringBootStarterTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/PropertiesShadowSpringBootStarterTest.java
@@ -38,6 +38,7 @@ import java.util.Map;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = PropertiesShadowSpringBootStarterTest.class)
@@ -59,14 +60,14 @@ public class PropertiesShadowSpringBootStarterTest {
ShadowAlgorithm userIdMatchAlgorithm = shadowAlgorithms.get("user-id-match-algorithm");
assertThat(userIdMatchAlgorithm, instanceOf(ColumnRegexMatchShadowAlgorithm.class));
assertThat(userIdMatchAlgorithm.getType(), is("REGEX_MATCH"));
- assertThat(userIdMatchAlgorithm.getProps().get("operation"), is("insert"));
- assertThat(userIdMatchAlgorithm.getProps().get("column"), is("user_id"));
- assertThat(userIdMatchAlgorithm.getProps().get("regex"), is("[1]"));
+ assertThat(userIdMatchAlgorithm.getProps().getProperty("operation"), is("insert"));
+ assertThat(userIdMatchAlgorithm.getProps().getProperty("column"), is("user_id"));
+ assertThat(userIdMatchAlgorithm.getProps().getProperty("regex"), is("[1]"));
ShadowAlgorithm simpleHintAlgorithm = shadowAlgorithms.get("simple-hint-algorithm");
assertThat(simpleHintAlgorithm, instanceOf(SimpleHintShadowAlgorithm.class));
assertThat(simpleHintAlgorithm.getType(), is("SIMPLE_HINT"));
- assertThat(simpleHintAlgorithm.getProps().get("shadow"), is(Boolean.TRUE.toString()));
- assertThat(simpleHintAlgorithm.getProps().get("foo"), is("bar"));
+ assertTrue(Boolean.parseBoolean(simpleHintAlgorithm.getProps().getProperty("shadow")));
+ assertThat(simpleHintAlgorithm.getProps().getProperty("foo"), is("bar"));
}
private void assertShadowTables(final Map<String, ShadowTableConfiguration> shadowTables) {
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/YmlShadowDefaultSpringBootStarterTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/YmlShadowDefaultSpringBootStarterTest.java
index 0ffd916aacc..cdd8127df34 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/YmlShadowDefaultSpringBootStarterTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/YmlShadowDefaultSpringBootStarterTest.java
@@ -57,8 +57,8 @@ public class YmlShadowDefaultSpringBootStarterTest {
ShadowAlgorithm simpleHintAlgorithm = shadowAlgorithms.get("simple-hint-algorithm");
assertThat(simpleHintAlgorithm, instanceOf(SimpleHintShadowAlgorithm.class));
assertThat(simpleHintAlgorithm.getType(), is("SIMPLE_HINT"));
- assertTrue((boolean) simpleHintAlgorithm.getProps().get("shadow"));
- assertThat(simpleHintAlgorithm.getProps().get("foo"), is("bar"));
+ assertTrue(Boolean.parseBoolean(simpleHintAlgorithm.getProps().getProperty("shadow")));
+ assertThat(simpleHintAlgorithm.getProps().getProperty("foo"), is("bar"));
}
private void assertShadowDataSources(final Map<String, ShadowDataSourceConfiguration> dataSources) {
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/YmlShadowSpringBootStarterTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/YmlShadowSpringBootStarterTest.java
index 214e1082fce..623e44c0de0 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/YmlShadowSpringBootStarterTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/YmlShadowSpringBootStarterTest.java
@@ -60,20 +60,20 @@ public class YmlShadowSpringBootStarterTest {
ShadowAlgorithm userIdRegexMatchAlgorithm = shadowAlgorithms.get("user-id-regex-match-algorithm");
assertThat(userIdRegexMatchAlgorithm, instanceOf(ColumnRegexMatchShadowAlgorithm.class));
assertThat(userIdRegexMatchAlgorithm.getType(), is("REGEX_MATCH"));
- assertThat(userIdRegexMatchAlgorithm.getProps().get("operation"), is("insert"));
- assertThat(userIdRegexMatchAlgorithm.getProps().get("column"), is("user_id"));
- assertThat(userIdRegexMatchAlgorithm.getProps().get("regex"), is("[1]"));
+ assertThat(userIdRegexMatchAlgorithm.getProps().getProperty("operation"), is("insert"));
+ assertThat(userIdRegexMatchAlgorithm.getProps().getProperty("column"), is("user_id"));
+ assertThat(userIdRegexMatchAlgorithm.getProps().getProperty("regex"), is("[1]"));
ShadowAlgorithm userIdValueMatchAlgorithm = shadowAlgorithms.get("user-id-value-match-algorithm");
assertThat(userIdValueMatchAlgorithm, instanceOf(ColumnValueMatchShadowAlgorithm.class));
assertThat(userIdValueMatchAlgorithm.getType(), is("VALUE_MATCH"));
- assertThat(userIdValueMatchAlgorithm.getProps().get("operation"), is("insert"));
- assertThat(userIdValueMatchAlgorithm.getProps().get("column"), is("user_id"));
- assertThat(userIdValueMatchAlgorithm.getProps().get("value"), is(1));
+ assertThat(userIdValueMatchAlgorithm.getProps().getProperty("operation"), is("insert"));
+ assertThat(userIdValueMatchAlgorithm.getProps().getProperty("column"), is("user_id"));
+ assertThat(userIdValueMatchAlgorithm.getProps().getProperty("value"), is("1"));
ShadowAlgorithm simpleHintAlgorithm = shadowAlgorithms.get("simple-hint-algorithm");
assertThat(simpleHintAlgorithm, instanceOf(SimpleHintShadowAlgorithm.class));
assertThat(simpleHintAlgorithm.getType(), is("SIMPLE_HINT"));
- assertTrue((boolean) simpleHintAlgorithm.getProps().get("shadow"));
- assertThat(simpleHintAlgorithm.getProps().get("foo"), is("bar"));
+ assertTrue(Boolean.parseBoolean(simpleHintAlgorithm.getProps().getProperty("shadow")));
+ assertThat(simpleHintAlgorithm.getProps().getProperty("foo"), is("bar"));
}
private void assertShadowTables(final Map<String, ShadowTableConfiguration> shadowTables) {
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/java/org/apache/shardingsphere/shadow/spring/namespace/ShadowAlgorithmSpringNamespaceTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/java/org/apache/shardingsphere/shadow/spring/namespace/ShadowAlgorithmSpringNamespaceTest.java
index cc402114cd0..cfb1365ea25 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/java/org/apache/shardingsphere/shadow/spring/namespace/ShadowAlgorithmSpringNamespaceTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/java/org/apache/shardingsphere/shadow/spring/namespace/ShadowAlgorithmSpringNamespaceTest.java
@@ -35,6 +35,7 @@ import java.util.Map;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
@ContextConfiguration(locations = "classpath:META-INF/spring/shadow-algorithm-application-context.xml")
public final class ShadowAlgorithmSpringNamespaceTest extends AbstractJUnit4SpringContextTests {
@@ -53,20 +54,20 @@ public final class ShadowAlgorithmSpringNamespaceTest extends AbstractJUnit4Spri
ShadowAlgorithm userIdRegexMatchAlgorithm = shadowAlgorithms.get("user-id-regex-match-algorithm");
assertThat(userIdRegexMatchAlgorithm, instanceOf(ColumnRegexMatchShadowAlgorithm.class));
assertThat(userIdRegexMatchAlgorithm.getType(), is("REGEX_MATCH"));
- assertThat(userIdRegexMatchAlgorithm.getProps().get("operation"), is("insert"));
- assertThat(userIdRegexMatchAlgorithm.getProps().get("column"), is("user_id"));
- assertThat(userIdRegexMatchAlgorithm.getProps().get("regex"), is("[1]"));
+ assertThat(userIdRegexMatchAlgorithm.getProps().getProperty("operation"), is("insert"));
+ assertThat(userIdRegexMatchAlgorithm.getProps().getProperty("column"), is("user_id"));
+ assertThat(userIdRegexMatchAlgorithm.getProps().getProperty("regex"), is("[1]"));
ShadowAlgorithm userIdValueMatchAlgorithm = shadowAlgorithms.get("user-id-value-match-algorithm");
assertThat(userIdValueMatchAlgorithm, instanceOf(ColumnValueMatchShadowAlgorithm.class));
assertThat(userIdValueMatchAlgorithm.getType(), is("VALUE_MATCH"));
- assertThat(userIdValueMatchAlgorithm.getProps().get("operation"), is("insert"));
- assertThat(userIdValueMatchAlgorithm.getProps().get("column"), is("user_id"));
- assertThat(userIdValueMatchAlgorithm.getProps().get("value"), is("1"));
+ assertThat(userIdValueMatchAlgorithm.getProps().getProperty("operation"), is("insert"));
+ assertThat(userIdValueMatchAlgorithm.getProps().getProperty("column"), is("user_id"));
+ assertThat(userIdValueMatchAlgorithm.getProps().getProperty("value"), is("1"));
ShadowAlgorithm simpleHintAlgorithm = shadowAlgorithms.get("simple-hint-algorithm");
assertThat(simpleHintAlgorithm, instanceOf(SimpleHintShadowAlgorithm.class));
assertThat(simpleHintAlgorithm.getType(), is("SIMPLE_HINT"));
- assertThat(simpleHintAlgorithm.getProps().get("shadow"), is(Boolean.TRUE.toString()));
- assertThat(simpleHintAlgorithm.getProps().get("foo"), is("bar"));
+ assertTrue(Boolean.parseBoolean(simpleHintAlgorithm.getProps().getProperty("shadow")));
+ assertThat(simpleHintAlgorithm.getProps().getProperty("foo"), is("bar"));
}
private void assertShadowTables(final Map<String, ShadowTableConfiguration> shadowTables) {
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/java/org/apache/shardingsphere/shadow/spring/namespace/ShadowDefaultAlgorithmSpringNamespaceTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/java/org/apache/shardingsphere/shadow/spring/namespace/ShadowDefaultAlgorithmSpringNamespaceTest.java
index f9569984caf..352333cc420 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/java/org/apache/shardingsphere/shadow/spring/namespace/ShadowDefaultAlgorithmSpringNamespaceTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/java/org/apache/shardingsphere/shadow/spring/namespace/ShadowDefaultAlgorithmSpringNamespaceTest.java
@@ -51,8 +51,8 @@ public final class ShadowDefaultAlgorithmSpringNamespaceTest extends AbstractJUn
ShadowAlgorithm simpleHintAlgorithm = shadowAlgorithms.get("simple-hint-algorithm");
assertThat(simpleHintAlgorithm, instanceOf(SimpleHintShadowAlgorithm.class));
assertThat(simpleHintAlgorithm.getType(), is("SIMPLE_HINT"));
- assertThat(simpleHintAlgorithm.getProps().get("shadow"), is(Boolean.TRUE.toString()));
- assertThat(simpleHintAlgorithm.getProps().get("foo"), is("bar"));
+ assertTrue(Boolean.parseBoolean(simpleHintAlgorithm.getProps().getProperty("shadow")));
+ assertThat(simpleHintAlgorithm.getProps().getProperty("foo"), is("bar"));
}
private void assertShadowDataSources(final Map<String, ShadowDataSourceConfiguration> dataSources) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/main/java/org/apache/shardingsphere/sharding/factory/KeyGenerateAlgorithmFactory.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/main/java/org/apache/shardingsphere/sharding/factory/KeyGenerateAlgorithmFactory.java
index a97ba303951..f7dfd2a512d 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/main/java/org/apache/shardingsphere/sharding/factory/KeyGenerateAlgorithmFactory.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/main/java/org/apache/shardingsphere/sharding/factory/KeyGenerateAlgorithmFactory.java
@@ -62,6 +62,6 @@ public final class KeyGenerateAlgorithmFactory {
* @return contains key generate algorithm or not
*/
public static boolean contains(final String keyGenerateAlgorithmType) {
- return TypedSPIRegistry.findRegisteredService(KeyGenerateAlgorithm.class, keyGenerateAlgorithmType, null).isPresent();
+ return TypedSPIRegistry.findRegisteredService(KeyGenerateAlgorithm.class, keyGenerateAlgorithmType).isPresent();
}
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/main/java/org/apache/shardingsphere/sharding/factory/ShardingAlgorithmFactory.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/main/java/org/apache/shardingsphere/sharding/factory/ShardingAlgorithmFactory.java
index a48d46348f9..c019494fe23 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/main/java/org/apache/shardingsphere/sharding/factory/ShardingAlgorithmFactory.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/main/java/org/apache/shardingsphere/sharding/factory/ShardingAlgorithmFactory.java
@@ -52,6 +52,6 @@ public final class ShardingAlgorithmFactory {
* @return contains sharding algorithm or not
*/
public static boolean contains(final String shardingAlgorithmType) {
- return TypedSPIRegistry.findRegisteredService(ShardingAlgorithm.class, shardingAlgorithmType, null).isPresent();
+ return TypedSPIRegistry.findRegisteredService(ShardingAlgorithm.class, shardingAlgorithmType).isPresent();
}
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/HashModShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/HashModShardingAlgorithm.java
index f3515695c6d..dab7a113315 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/HashModShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/HashModShardingAlgorithm.java
@@ -48,7 +48,7 @@ public final class HashModShardingAlgorithm implements StandardShardingAlgorithm
private int getShardingCount(final Properties props) {
Preconditions.checkArgument(props.containsKey(SHARDING_COUNT_KEY), "Sharding count cannot be null.");
- return Integer.parseInt(props.get(SHARDING_COUNT_KEY).toString());
+ return Integer.parseInt(props.getProperty(SHARDING_COUNT_KEY));
}
@Override
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithm.java
index 28e02dbe899..ff96a31cc6e 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithm.java
@@ -49,7 +49,7 @@ public final class ModShardingAlgorithm implements StandardShardingAlgorithm<Com
private int getShardingCount(final Properties props) {
Preconditions.checkArgument(props.containsKey(SHARDING_COUNT_KEY), "Sharding count cannot be null.");
- return Integer.parseInt(props.get(SHARDING_COUNT_KEY).toString());
+ return Integer.parseInt(props.getProperty(SHARDING_COUNT_KEY));
}
@Override
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/VolumeBasedRangeShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/VolumeBasedRangeShardingAlgorithm.java
index 22604d95f44..8b4f236f5bd 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/VolumeBasedRangeShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/VolumeBasedRangeShardingAlgorithm.java
@@ -48,9 +48,9 @@ public final class VolumeBasedRangeShardingAlgorithm extends AbstractRangeShardi
Preconditions.checkState(props.containsKey(RANGE_LOWER_KEY), "Lower range cannot be null.");
Preconditions.checkState(props.containsKey(RANGE_UPPER_KEY), "Upper range cannot be null.");
Preconditions.checkState(props.containsKey(SHARDING_VOLUME_KEY), "Sharding volume cannot be null.");
- long lower = Long.parseLong(props.get(RANGE_LOWER_KEY).toString());
- long upper = Long.parseLong(props.get(RANGE_UPPER_KEY).toString());
- long volume = Long.parseLong(props.get(SHARDING_VOLUME_KEY).toString());
+ long lower = Long.parseLong(props.getProperty(RANGE_LOWER_KEY));
+ long upper = Long.parseLong(props.getProperty(RANGE_UPPER_KEY));
+ long volume = Long.parseLong(props.getProperty(SHARDING_VOLUME_KEY));
Preconditions.checkArgument(upper - lower >= volume, "Range can not be smaller than volume.");
int partitionSize = Math.toIntExact(LongMath.divide(upper - lower, volume, RoundingMode.CEILING));
Map<Integer, Range<Comparable<?>>> result = new HashMap<>(partitionSize + 2, 1);
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/converter/ShardingRuleStatementConverterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/converter/ShardingRuleStatementConverterTest.java
index b540c0f3f30..d507fda17b5 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/converter/ShardingRuleStatementConverterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/converter/ShardingRuleStatementConverterTest.java
@@ -63,10 +63,10 @@ public final class ShardingRuleStatementConverterTest {
assertThat(autoTableRule.getKeyGenerateStrategy().getKeyGeneratorName(), is("snowflake_algorithm"));
assertThat(config.getShardingAlgorithms().size(), is(3));
assertThat(config.getShardingAlgorithms().get("t_order_mod").getType(), is("mod"));
- assertThat(config.getShardingAlgorithms().get("t_order_mod").getProps().get("sharding_count"), is("2"));
+ assertThat(config.getShardingAlgorithms().get("t_order_mod").getProps().getProperty("sharding_count"), is("2"));
assertThat(config.getKeyGenerators().size(), is(1));
assertThat(config.getKeyGenerators().get("t_order_snowflake").getType(), is("snowflake"));
- assertThat(config.getKeyGenerators().get("t_order_snowflake").getProps().get(""), is(""));
+ assertThat(config.getKeyGenerators().get("t_order_snowflake").getProps().getProperty(""), is(""));
}
private Collection<AbstractTableRuleSegment> createTableRuleSegment1() {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdKeyGenerateAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdKeyGenerateAlgorithm.java
index 55d67e44b72..74ae7f6c2f5 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdKeyGenerateAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdKeyGenerateAlgorithm.java
@@ -47,7 +47,7 @@ public final class CosIdKeyGenerateAlgorithm implements KeyGenerateAlgorithm {
@Override
public void init(final Properties props) {
lazyIdGenerator = new LazyIdGenerator(props.getProperty(CosIdAlgorithmConstants.ID_NAME_KEY, IdGeneratorProvider.SHARE));
- asString = props.containsKey(AS_STRING_KEY) ? Boolean.parseBoolean(props.get(AS_STRING_KEY).toString()) : Boolean.FALSE;
+ asString = Boolean.parseBoolean(props.getProperty(AS_STRING_KEY, Boolean.FALSE.toString()));
lazyIdGenerator.tryGet(false);
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithm.java
index 96024039167..ee826d74a9e 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithm.java
@@ -77,7 +77,7 @@ public final class CosIdSnowflakeKeyGenerateAlgorithm implements KeyGenerateAlgo
}
private long getEpoch(final Properties props) {
- return props.containsKey(EPOCH_KEY) ? Long.parseLong(props.get(EPOCH_KEY).toString()) : DEFAULT_EPOCH;
+ return Long.parseLong(props.getProperty(EPOCH_KEY, DEFAULT_EPOCH + ""));
}
@Override
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/AbstractCosIdIntervalShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/AbstractCosIdIntervalShardingAlgorithm.java
index 4792cf5f638..ff00b7f03f1 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/AbstractCosIdIntervalShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/AbstractCosIdIntervalShardingAlgorithm.java
@@ -69,7 +69,7 @@ public abstract class AbstractCosIdIntervalShardingAlgorithm<T extends Comparabl
}
private ZoneId getZoneId(final Properties props) {
- return props.containsKey(ZONE_ID_KEY) ? ZoneId.of(props.get(ZONE_ID_KEY).toString()) : ZoneId.systemDefault();
+ return props.containsKey(ZONE_ID_KEY) ? ZoneId.of(props.getProperty(ZONE_ID_KEY)) : ZoneId.systemDefault();
}
private IntervalTimeline getIntervalTimeline(final Properties props) {
@@ -84,7 +84,7 @@ public abstract class AbstractCosIdIntervalShardingAlgorithm<T extends Comparabl
private String getRequiredValue(final Properties props, final String key) {
Preconditions.checkArgument(props.containsKey(key), "%s can not be null.", key);
- return props.get(key).toString();
+ return props.getProperty(key);
}
@Override
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/CosIdSnowflakeIntervalShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/CosIdSnowflakeIntervalShardingAlgorithm.java
index 1f0b4058623..2db3f9b4d54 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/CosIdSnowflakeIntervalShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/CosIdSnowflakeIntervalShardingAlgorithm.java
@@ -52,7 +52,7 @@ public final class CosIdSnowflakeIntervalShardingAlgorithm extends AbstractCosId
}
private SnowflakeIdStateParser getSnowflakeIdStateParser(final Properties props) {
- long epoch = props.containsKey(EPOCH_KEY) ? Long.parseLong(props.get(EPOCH_KEY).toString()) : CosIdSnowflakeKeyGenerateAlgorithm.DEFAULT_EPOCH;
+ long epoch = Long.parseLong(props.getProperty(EPOCH_KEY, CosIdSnowflakeKeyGenerateAlgorithm.DEFAULT_EPOCH + ""));
return new MillisecondSnowflakeIdStateParser(
epoch, MillisecondSnowflakeId.DEFAULT_TIMESTAMP_BIT, MillisecondSnowflakeId.DEFAULT_MACHINE_BIT, MillisecondSnowflakeId.DEFAULT_SEQUENCE_BIT, getZoneId());
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/mod/CosIdModShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/mod/CosIdModShardingAlgorithm.java
index ef5dc4fb560..a2e416d3a11 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/mod/CosIdModShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/mod/CosIdModShardingAlgorithm.java
@@ -54,7 +54,7 @@ public final class CosIdModShardingAlgorithm<T extends Number & Comparable<T>> i
private String getRequiredValue(final Properties props, final String key) {
Preconditions.checkArgument(props.containsKey(key), "%s can not be null.", key);
- return props.get(key).toString();
+ return props.getProperty(key);
}
@Override
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-boot-starter-infra/src/main/java/org/apache/shardingsphere/spring/boot/registry/AbstractAlgorithmProvidedBeanRegistry.java b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-boot-starter-infra/src/main/java/org/apache/shardingsphere/spring/boot/registry/AbstractAlgorithmProvidedBeanRegistry.java
index aa2e9ce98e8..1b419587ef2 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-boot-starter-infra/src/main/java/org/apache/shardingsphere/spring/boot/registry/AbstractAlgorithmProvidedBeanRegistry.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-boot-starter-infra/src/main/java/org/apache/shardingsphere/spring/boot/registry/AbstractAlgorithmProvidedBeanRegistry.java
@@ -33,6 +33,7 @@ import org.springframework.core.env.Environment;
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
import java.util.stream.Collectors;
@@ -95,8 +96,19 @@ public abstract class AbstractAlgorithmProvidedBeanRegistry<T extends ShardingSp
public final Object postProcessAfterInitialization(final Object bean, final String beanName) {
if (bean instanceof ShardingSphereAlgorithm) {
ShardingSphereAlgorithm algorithm = (ShardingSphereAlgorithm) bean;
- algorithm.init(algorithm.getProps());
+ Properties stringTypeProps = convertToStringTypedProperties(algorithm.getProps());
+ algorithm.init(stringTypeProps);
+ algorithm.setProps(stringTypeProps);
}
return bean;
}
+
+ private static Properties convertToStringTypedProperties(final Properties props) {
+ if (null == props) {
+ return new Properties();
+ }
+ Properties result = new Properties();
+ props.forEach((key, value) -> result.setProperty(key.toString(), null == value ? null : value.toString()));
+ return result;
+ }
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/detect/JobCompletionDetectAlgorithmFactory.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/detect/JobCompletionDetectAlgorithmFactory.java
index b50637f5995..53a698ca9f4 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/detect/JobCompletionDetectAlgorithmFactory.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/detect/JobCompletionDetectAlgorithmFactory.java
@@ -52,6 +52,6 @@ public final class JobCompletionDetectAlgorithmFactory {
* @return contains job completion detect algorithm or not
*/
public static boolean contains(final String jobCompletionDetectAlgorithmType) {
- return TypedSPIRegistry.findRegisteredService(JobCompletionDetectAlgorithm.class, jobCompletionDetectAlgorithmType, null).isPresent();
+ return TypedSPIRegistry.findRegisteredService(JobCompletionDetectAlgorithm.class, jobCompletionDetectAlgorithmType).isPresent();
}
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ingest/channel/PipelineChannelCreatorFactory.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ingest/channel/PipelineChannelCreatorFactory.java
index 4d01b3fa2c1..fd6f26b95fa 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ingest/channel/PipelineChannelCreatorFactory.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ingest/channel/PipelineChannelCreatorFactory.java
@@ -51,6 +51,6 @@ public final class PipelineChannelCreatorFactory {
* @return contains pipeline channel creator or not
*/
public static boolean contains(final String pipelineChannelCreatorType) {
- return TypedSPIRegistry.findRegisteredService(PipelineChannelCreator.class, pipelineChannelCreatorType, null).isPresent();
+ return TypedSPIRegistry.findRegisteredService(PipelineChannelCreator.class, pipelineChannelCreatorType).isPresent();
}
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ratelimit/JobRateLimitAlgorithmFactory.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ratelimit/JobRateLimitAlgorithmFactory.java
index e65d2396178..83de7b83ef2 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ratelimit/JobRateLimitAlgorithmFactory.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ratelimit/JobRateLimitAlgorithmFactory.java
@@ -51,6 +51,6 @@ public final class JobRateLimitAlgorithmFactory {
* @return contains job rate limit algorithm or not
*/
public static boolean contains(final String jobRateLimitAlgorithmType) {
- return TypedSPIRegistry.findRegisteredService(JobRateLimitAlgorithm.class, jobRateLimitAlgorithmType, null).isPresent();
+ return TypedSPIRegistry.findRegisteredService(JobRateLimitAlgorithm.class, jobRateLimitAlgorithmType).isPresent();
}
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/factory/TrafficAlgorithmFactory.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/factory/TrafficAlgorithmFactory.java
index 80fd3722a43..475bf1cfc2e 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/factory/TrafficAlgorithmFactory.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/factory/TrafficAlgorithmFactory.java
@@ -52,6 +52,6 @@ public final class TrafficAlgorithmFactory {
* @return contains traffic algorithm or not
*/
public static boolean contains(final String trafficAlgorithmType) {
- return TypedSPIRegistry.findRegisteredService(TrafficAlgorithm.class, trafficAlgorithmType, null).isPresent();
+ return TypedSPIRegistry.findRegisteredService(TrafficAlgorithm.class, trafficAlgorithmType).isPresent();
}
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/factory/TrafficLoadBalanceAlgorithmFactory.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/factory/TrafficLoadBalanceAlgorithmFactory.java
index 7b842fe804f..2510a5b5a96 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/factory/TrafficLoadBalanceAlgorithmFactory.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/factory/TrafficLoadBalanceAlgorithmFactory.java
@@ -52,6 +52,6 @@ public final class TrafficLoadBalanceAlgorithmFactory {
* @return contains traffic load balance algorithm or not
*/
public static boolean contains(final String trafficLoadBalanceAlgorithmType) {
- return TypedSPIRegistry.findRegisteredService(TrafficLoadBalanceAlgorithm.class, trafficLoadBalanceAlgorithmType, null).isPresent();
+ return TypedSPIRegistry.findRegisteredService(TrafficLoadBalanceAlgorithm.class, trafficLoadBalanceAlgorithmType).isPresent();
}
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLRegexTrafficAlgorithm.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLRegexTrafficAlgorithm.java
index 0ee73dbaba5..e83b1bcce0b 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLRegexTrafficAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLRegexTrafficAlgorithm.java
@@ -41,8 +41,8 @@ public final class SQLRegexTrafficAlgorithm implements SegmentTrafficAlgorithm {
@Override
public void init(final Properties props) {
- Preconditions.checkArgument(props.containsKey(REGEX_PROPS_KEY), "%s cannot be null.", REGEX_PROPS_KEY);
- regex = Pattern.compile(String.valueOf(props.get(REGEX_PROPS_KEY)));
+ Preconditions.checkArgument(props.containsKey(REGEX_PROPS_KEY), "%s can not be null.", REGEX_PROPS_KEY);
+ regex = Pattern.compile(props.getProperty(REGEX_PROPS_KEY));
}
@Override
diff --git a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerTest.java b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerTest.java
index 56f7f127ae1..173e4414952 100644
--- a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerTest.java
+++ b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerTest.java
@@ -251,7 +251,7 @@ public final class ContextManagerTest {
Properties props = new Properties();
props.put("foo", "foo_value");
contextManager.alterProperties(props);
- assertThat(contextManager.getMetaDataContexts().getProps().getProps().get("foo"), is("foo_value"));
+ assertThat(contextManager.getMetaDataContexts().getProps().getProps().getProperty("foo"), is("foo_value"));
}
@Test
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoaderTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoaderTest.java
index cbdb92dd548..f22c663cd73 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoaderTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoaderTest.java
@@ -93,8 +93,8 @@ public final class ProxyConfigurationLoaderTest {
private void assertReadwriteSplittingRuleConfiguration(final YamlReadwriteSplittingDataSourceRuleConfiguration actual) {
assertNotNull(actual.getProps());
- assertThat(actual.getProps().get("write-data-source-name"), is("write_ds"));
- assertThat(actual.getProps().get("read-data-source-names"), is("read_ds_0,read_ds_1"));
+ assertThat(actual.getProps().getProperty("write-data-source-name"), is("write_ds"));
+ assertThat(actual.getProps().getProperty("read-data-source-names"), is("read_ds_0,read_ds_1"));
}
private void assertEncryptRuleConfiguration(final YamlProxyDatabaseConfiguration actual) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/SetVariableExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/SetVariableExecutorTest.java
index 6fce75d2725..126eba8b3d6 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/SetVariableExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/SetVariableExecutorTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.updatable;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.updatable.SetVariableStatement;
+import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
@@ -72,6 +73,8 @@ public final class SetVariableExecutorTest {
new SetVariableHandler().init(getParameter(statement, connectionSession)).execute();
Object actualValue = contextManager.getMetaDataContexts().getProps().getProps().get("proxy-frontend-flush-threshold");
assertThat(actualValue.toString(), is("1024"));
+ // FIXME should be 1024, but is 128
+ assertThat(contextManager.getMetaDataContexts().getProps().getValue(ConfigurationPropertyKey.PROXY_FRONTEND_FLUSH_THRESHOLD), is(128));
}
private HandlerParameter<SetVariableStatement> getParameter(final SetVariableStatement statement, final ConnectionSession connectionSession) {
diff --git a/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/typed/TypedSPIRegistry.java b/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/typed/TypedSPIRegistry.java
index 9deb2378eb5..8b704fb9450 100644
--- a/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/typed/TypedSPIRegistry.java
+++ b/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/typed/TypedSPIRegistry.java
@@ -62,12 +62,12 @@ public final class TypedSPIRegistry {
public static <T extends TypedSPI> Optional<T> findRegisteredService(final Class<T> spiClass, final String type, final Properties props) {
for (T each : ShardingSphereServiceLoader.getServiceInstances(spiClass)) {
if (matchesType(type, each)) {
- // TODO for AlgorithmFactory contains judge only, should fix here
- if (null != props && each instanceof SPIPostProcessor) {
- init((SPIPostProcessor) each, props);
+ Properties stringTypeProps = convertToStringTypedProperties(props);
+ if (each instanceof SPIPostProcessor) {
+ ((SPIPostProcessor) each).init(stringTypeProps);
}
if (each instanceof SPIPropertiesAware) {
- ((SPIPropertiesAware) each).setProps(null == props ? new Properties() : props);
+ ((SPIPropertiesAware) each).setProps(stringTypeProps);
}
return Optional.of(each);
}
@@ -79,10 +79,13 @@ public final class TypedSPIRegistry {
return typedSPI.getType().equalsIgnoreCase(type) || typedSPI.getTypeAliases().contains(type);
}
- private static <T extends SPIPostProcessor> void init(final T spiPostProcessor, final Properties props) {
- Properties newProps = new Properties();
- props.forEach((key, value) -> newProps.setProperty(key.toString(), null == value ? null : value.toString()));
- spiPostProcessor.init(newProps);
+ private static Properties convertToStringTypedProperties(final Properties props) {
+ if (null == props) {
+ return new Properties();
+ }
+ Properties result = new Properties();
+ props.forEach((key, value) -> result.setProperty(key.toString(), null == value ? null : value.toString()));
+ return result;
}
/**