You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "shengdoupi (via GitHub)" <gi...@apache.org> on 2023/04/12 04:24:17 UTC

[GitHub] [shardingsphere] shengdoupi commented on a diff in pull request #25122: improve properties verification of key generate algorithms

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


##########
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:
   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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org