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

[GitHub] [shardingsphere] Pace2Car commented on a diff in pull request #25041: [#24755] Improve property verification of MaskAlgorithm

Pace2Car commented on code in PR #25041:
URL: https://github.com/apache/shardingsphere/pull/25041#discussion_r1184490043


##########
features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFromXToYMaskAlgorithm.java:
##########
@@ -49,17 +51,29 @@ public void init(final Properties props) {
     
     private Integer createFromX(final Properties props) {
         MaskAlgorithmPropsChecker.checkIntegerTypeConfig(props, FROM_X, getType());
-        return Integer.parseInt(props.getProperty(FROM_X));
+        String fromXValue = props.getProperty(FROM_X);
+        if (!Strings.isNullOrEmpty(fromXValue)) {
+            fromX = Integer.parseInt(fromXValue);
+            ShardingSpherePreconditions.checkState(fromX > 0, () -> new MaskAlgorithmInitializationException(getType(), "from-X must be a positive integer."));
+        }
+        return fromX;

Review Comment:
   This code is reused and looks like it can be extracted to `Checker` class.



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