shengdoupi commented on code in PR #25122:
URL: https://github.com/apache/shardingsphere/pull/25122#discussion_r1163582857


##########
features/sharding/plugin/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithm.java:
##########
@@ -73,7 +73,10 @@ private boolean getAsString(final Properties props) {
     }
     
     private long getEpoch(final Properties props) {
-        return Long.parseLong(props.getProperty(EPOCH_KEY, DEFAULT_EPOCH + 
""));
+        long result = Long.parseLong(props.getProperty(EPOCH_KEY, 
DEFAULT_EPOCH + ""));
+        ShardingSpherePreconditions.checkState(result > 0L,
+                () -> new ShardingPluginException("Key generate algorithm `%s` 
initialization failed, reason is: %s.", getType(), "Epoch must be positive."));

Review Comment:
   > Should use KeyGenerateAlgorithmInitializationException here.
   
   @Pace2Car Thanks! If I use 
org.apache.shardingsphere.sharding.exception.algorithm.keygen.KeyGenerateAlgorithmInitializationException
 here, I need to add dependency on module "shardingsphere-sharding-core", which 
will cause a circular dependency between "shardingsphere-sharding-cosid" and 
"shardingsphere-sharding-core". May I create a new 
KeyGenerateAlgorithmInitializationException class in the same package as 
ShardingPluginException to solve this problem?



-- 
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]

Reply via email to