diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/replace/GenericTableRandomReplaceAlgorithm.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/replace/GenericTableRandomReplaceAlgorithm.java index 0e14b329a4429..9a3d9b849e721 100644 --- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/replace/GenericTableRandomReplaceAlgorithm.java +++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/replace/GenericTableRandomReplaceAlgorithm.java @@ -83,11 +83,11 @@ public String mask(final Object plainValue) { char[] chars = result.toCharArray(); for (int i = 0; i < chars.length; i++) { char c = chars[i]; - if ('A' <= c && c <= 'Z') { + if (c >= 'A' && c <= 'Z') { chars[i] = uppercaseLetterCodes.get(random.nextInt(uppercaseLetterCodes.size())); - } else if ('a' <= c && c <= 'z') { + } else if (c >= 'a' && c <= 'z') { chars[i] = lowercaseLetterCodes.get(random.nextInt(lowercaseLetterCodes.size())); - } else if ('0' <= c && c <= '9') { + } else if (c >= '0' && c <= '9') { chars[i] = digitalCodes.get(random.nextInt(digitalCodes.size())); } else { chars[i] = specialCodes.get(random.nextInt(specialCodes.size())); diff --git a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/replace/GenericTableRandomReplaceAlgorithmTest.java b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/replace/GenericTableRandomReplaceAlgorithmTest.java index e8341b3f31049..ab40ff68801e1 100644 --- a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/replace/GenericTableRandomReplaceAlgorithmTest.java +++ b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/replace/GenericTableRandomReplaceAlgorithmTest.java @@ -31,6 +31,7 @@ import static org.hamcrest.CoreMatchers.anyOf; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertNull; class GenericTableRandomReplaceAlgorithmTest { @@ -39,6 +40,7 @@ void assertMask() { GenericTableRandomReplaceAlgorithm maskAlgorithm = (GenericTableRandomReplaceAlgorithm) TypedSPILoader.getService(MaskAlgorithm.class, "GENERIC_TABLE_RANDOM_REPLACE", PropertiesBuilder.build(new Property("uppercase-letter-codes", "A,B,C,D"), new Property("lowercase-letter-codes", "a,b,c,d"), new Property("digital-codes", "1,2,3,4"), new Property("special-codes", "~!@#"))); + assertNull(maskAlgorithm.mask(null)); assertThat(maskAlgorithm.mask(""), is("")); assertThat(maskAlgorithm.mask("Ab1!").charAt(0), anyOf(is('A'), is('B'), is('C'), is('D'))); assertThat(maskAlgorithm.mask("Ab1!").charAt(1), anyOf(is('a'), is('b'), is('c'), is('d'))); @@ -49,6 +51,7 @@ void assertMask() { @Test void assertMaskWithEmptyProps() { GenericTableRandomReplaceAlgorithm maskAlgorithm = (GenericTableRandomReplaceAlgorithm) TypedSPILoader.getService(MaskAlgorithm.class, "GENERIC_TABLE_RANDOM_REPLACE", new Properties()); + assertNull(maskAlgorithm.mask(null)); assertThat(maskAlgorithm.mask("Ab1!").substring(0, 1), anyOf(Arrays.stream("ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("")).map(CoreMatchers::is).collect(Collectors.toList()))); assertThat(maskAlgorithm.mask("Ab1!").substring(1, 2), anyOf(Arrays.stream("abcdefghijklmnopqrstuvwxyz".split("")).map(CoreMatchers::is).collect(Collectors.toList()))); assertThat(maskAlgorithm.mask("Ab1!").substring(2, 3), anyOf(Arrays.stream("0123456789".split("")).map(CoreMatchers::is).collect(Collectors.toList()))); diff --git a/kernel/data-pipeline/dialect/opengauss/src/test/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/incremental/wal/decode/MppdbDecodingPluginTest.java b/kernel/data-pipeline/dialect/opengauss/src/test/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/incremental/wal/decode/MppdbDecodingPluginTest.java index 4a00864fb828b..219e35e25fa78 100644 --- a/kernel/data-pipeline/dialect/opengauss/src/test/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/incremental/wal/decode/MppdbDecodingPluginTest.java +++ b/kernel/data-pipeline/dialect/opengauss/src/test/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/incremental/wal/decode/MppdbDecodingPluginTest.java @@ -52,9 +52,7 @@ class MppdbDecodingPluginTest { - private final LogSequenceNumber pgSequenceNumber = LogSequenceNumber.valueOf("0/14EFDB8"); - - private final OpenGaussLogSequenceNumber logSequenceNumber = new OpenGaussLogSequenceNumber(pgSequenceNumber); + private final OpenGaussLogSequenceNumber logSequenceNumber = new OpenGaussLogSequenceNumber(LogSequenceNumber.valueOf("0/14EFDB8")); @Test void assertDecodeWriteRowEvent() {