Pace2Car commented on code in PR #25041:
URL: https://github.com/apache/shardingsphere/pull/25041#discussion_r1169728258
##########
features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFirstNLastMMaskAlgorithm.java:
##########
@@ -48,18 +50,32 @@ public void init(final Properties props) {
}
private Integer createFirstN(final Properties props) {
+ int firstN = 0;
MaskAlgorithmPropsChecker.checkIntegerTypeConfig(props, FIRST_N,
getType());
- return Integer.parseInt(props.getProperty(FIRST_N));
+ String firstNValue = props.getProperty(FIRST_N);
+ if (!Strings.isNullOrEmpty(firstNValue)) {
+ firstN = Integer.parseInt(firstNValue);
+ ShardingSpherePreconditions.checkState(firstN > 0, () -> new
MaskAlgorithmInitializationException(getType(), "first-n must be a positive
integer."));
+ }
+ return firstN;
}
private Integer createLastM(final Properties props) {
+ int lastM = 0;
MaskAlgorithmPropsChecker.checkIntegerTypeConfig(props, LAST_M,
getType());
- return Integer.parseInt(props.getProperty(LAST_M));
+ String lastMValue = props.getProperty(LAST_M);
+ if (!Strings.isNullOrEmpty(lastMValue)) {
+ lastM = Integer.parseInt(lastMValue);
+ ShardingSpherePreconditions.checkState(lastM > 0, () -> new
MaskAlgorithmInitializationException(getType(), "first-n must be a positive
integer."));
+ }
+ return lastM;
}
private Character createReplaceChar(final Properties props) {
+ String replaceCharStr = props.getProperty(REPLACE_CHAR);
Review Comment:
This line seems unnecessary.
--
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]