liuxiaocs7 commented on code in PR #25246:
URL: https://github.com/apache/shardingsphere/pull/25246#discussion_r1176362786
##########
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithm.java:
##########
@@ -59,15 +60,18 @@ public void init(final Properties props) {
private ClassBasedShardingAlgorithmStrategyType getStrategy(final
Properties props) {
String strategy = props.getProperty(STRATEGY_KEY);
- ShardingSpherePreconditions.checkNotNull(strategy,
- () -> new ShardingAlgorithmInitializationException(getType(),
String.format("Properties `%s` can not be null when uses class based sharding
strategy.", STRATEGY_KEY)));
- return
ClassBasedShardingAlgorithmStrategyType.valueOf(strategy.toUpperCase().trim());
+
ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(strategy),
+ () -> new ShardingAlgorithmInitializationException(getType(),
String.format("Properties `%s` can not be null or empty when uses class based
sharding strategy", STRATEGY_KEY)));
+ String shardingAlgorithmStrategyType = strategy.toUpperCase().trim();
+ ShardingSpherePreconditions.checkState(
+
ClassBasedShardingAlgorithmStrategyType.isValidShardingAlgorithmStrategyType(shardingAlgorithmStrategyType),
+ () -> new ShardingAlgorithmInitializationException(getType(),
String.format("Sharding strategy `%s` not support", strategy)));
+ return
ClassBasedShardingAlgorithmStrategyType.valueOf(shardingAlgorithmStrategyType);
}
private String getAlgorithmClassName(final Properties props) {
String result = props.getProperty(ALGORITHM_CLASS_NAME_KEY);
- ShardingSpherePreconditions.checkNotNull(result,
- () -> new ShardingAlgorithmInitializationException(getType(),
String.format("Properties `%s` can not be null when uses class based sharding
strategy.", ALGORITHM_CLASS_NAME_KEY)));
+ ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(result),
() -> new ShardingAlgorithmInitializationException(getType(), "Sharding
algorithm ClassName can not be null or empty"));
Review Comment:
fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]