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

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

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


##########
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java:
##########
@@ -113,7 +113,9 @@ private int getMaxVibrationOffset(final Properties props) {
     }
     
     private int getMaxTolerateTimeDifferenceMilliseconds(final Properties props) {
-        return Integer.parseInt(props.getOrDefault(MAX_TOLERATE_TIME_DIFFERENCE_MILLISECONDS_KEY, MAX_TOLERATE_TIME_DIFFERENCE_MILLISECONDS).toString());
+        int result = Integer.parseInt(props.getOrDefault(MAX_TOLERATE_TIME_DIFFERENCE_MILLISECONDS_KEY, MAX_TOLERATE_TIME_DIFFERENCE_MILLISECONDS).toString());

Review Comment:
   Hi @shengdoupi 
   `Integer.parseInt` may throw `NumberFormatException` (when value is not a number), so try catch is needed here and wrapped as `KeyGenerateAlgorithmInitializationException`



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