This is an automated email from the ASF dual-hosted git repository.

jianglongtao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 638186bffd0 Refactor throw IllegalArgumentException to 
Preconditions.checkArgument (#21122)
638186bffd0 is described below

commit 638186bffd0be380ee6a5fb0da94d1949aebc036
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Sep 22 00:39:20 2022 +0800

    Refactor throw IllegalArgumentException to Preconditions.checkArgument 
(#21122)
    
    * Refactor throw IllegalArgumentException to Preconditions.checkState
    
    * Refactor throw IllegalArgumentException to Preconditions.checkState
    
    * Refactor throw IllegalArgumentException to Preconditions.checkArgument
    
    * Refactor throw IllegalArgumentException to Preconditions.checkArgument
---
 .../db/protocol/mysql/constant/MySQLBinaryColumnType.java  | 13 +++++--------
 .../db/protocol/mysql/constant/MySQLBinlogEventType.java   |  7 +++----
 .../mysql/constant/MySQLNewParametersBoundFlag.java        |  2 +-
 .../execute/protocol/MySQLDateBinaryProtocolValue.java     |  2 +-
 .../execute/protocol/MySQLTimeBinaryProtocolValue.java     |  2 +-
 .../packet/command/PostgreSQLCommandPacketType.java        |  2 +-
 .../command/query/extended/PostgreSQLColumnType.java       |  9 ++++-----
 .../bind/protocol/PostgreSQLArrayParameterDecoder.java     |  9 +++------
 .../extended/bind/protocol/PostgreSQLByteConverter.java    | 12 ++----------
 .../packet/identifier/PostgreSQLMessagePacketType.java     |  2 +-
 .../sharding/complex/ComplexInlineShardingAlgorithm.java   |  5 ++---
 .../infra/datasource/state/DataSourceState.java            |  7 +++----
 .../yaml/constructor/ShardingSphereYamlConstructor.java    |  7 +++----
 .../api/ingest/position/PrimaryKeyPositionFactory.java     |  6 +++---
 .../config/process/PipelineProcessConfigurationUtil.java   |  5 ++---
 .../data/pipeline/core/job/PipelineJobIdUtils.java         | 12 +++++-------
 .../registry/CoordinatorRegistryCenterInitializer.java     | 14 ++++++--------
 .../core/sqlbuilder/AbstractPipelineSQLBuilder.java        |  9 ++++-----
 .../pipeline/core/sqlbuilder/OraclePipelineSQLBuilder.java | 14 ++++++--------
 .../opengauss/ingest/wal/decode/MppdbDecodingPlugin.java   |  9 +++------
 .../postgresql/ingest/wal/decode/TestDecodingPlugin.java   |  9 +++------
 .../authentication/OpenGaussAuthenticationHandler.java     |  5 ++---
 .../test/integration/cases/dataset/DataSet.java            | 10 ++--------
 .../test/integration/cases/dataset/DataSetLoader.java      |  7 +++----
 .../parameterized/jaxb/sql/loader/SQLCasesLoader.java      |  5 +----
 .../scenario/EncryptSQLRewriterParameterizedTest.java      |  2 +-
 .../scenario/MixSQLRewriterParameterizedTest.java          |  2 +-
 .../scenario/ShardingSQLRewriterParameterizedTest.java     |  2 +-
 28 files changed, 73 insertions(+), 117 deletions(-)

diff --git 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLBinaryColumnType.java
 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLBinaryColumnType.java
index 3172c0832bc..5c32262b0cf 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLBinaryColumnType.java
+++ 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLBinaryColumnType.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.db.protocol.mysql.constant;
 
+import com.google.common.base.Preconditions;
 import lombok.Getter;
 import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.db.protocol.binary.BinaryColumnType;
@@ -142,10 +143,8 @@ public enum MySQLBinaryColumnType implements 
BinaryColumnType {
      * @return column type enum
      */
     public static MySQLBinaryColumnType valueOfJDBCType(final int jdbcType) {
-        if (JDBC_TYPE_AND_COLUMN_TYPE_MAP.containsKey(jdbcType)) {
-            return JDBC_TYPE_AND_COLUMN_TYPE_MAP.get(jdbcType);
-        }
-        throw new IllegalArgumentException(String.format("Cannot find JDBC 
type '%s' in column type", jdbcType));
+        
Preconditions.checkArgument(JDBC_TYPE_AND_COLUMN_TYPE_MAP.containsKey(jdbcType),
 "Can not find JDBC type `%s` in column type", jdbcType);
+        return JDBC_TYPE_AND_COLUMN_TYPE_MAP.get(jdbcType);
     }
     
     /**
@@ -155,9 +154,7 @@ public enum MySQLBinaryColumnType implements 
BinaryColumnType {
      * @return column type
      */
     public static MySQLBinaryColumnType valueOf(final int value) {
-        if (VALUE_AND_COLUMN_TYPE_MAP.containsKey(value)) {
-            return VALUE_AND_COLUMN_TYPE_MAP.get(value);
-        }
-        throw new IllegalArgumentException(String.format("Cannot find value 
'%s' in column type", value));
+        
Preconditions.checkArgument(VALUE_AND_COLUMN_TYPE_MAP.containsKey(value), "Can 
not find value `%s` in column type", value);
+        return VALUE_AND_COLUMN_TYPE_MAP.get(value);
     }
 }
diff --git 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLBinlogEventType.java
 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLBinlogEventType.java
index 72722490d09..f52dc2efa59 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLBinlogEventType.java
+++ 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLBinlogEventType.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.db.protocol.mysql.constant;
 
+import com.google.common.base.Preconditions;
 import lombok.Getter;
 import lombok.RequiredArgsConstructor;
 
@@ -121,9 +122,7 @@ public enum MySQLBinlogEventType {
      * @return MySQL binlog event type
      */
     public static MySQLBinlogEventType valueOf(final int value) {
-        if (VALUE_AND_EVENT_TYPE_MAP.containsKey(value)) {
-            return VALUE_AND_EVENT_TYPE_MAP.get(value);
-        }
-        throw new IllegalArgumentException(String.format("Cannot find value 
'%s' in binlog event type", value));
+        
Preconditions.checkArgument(VALUE_AND_EVENT_TYPE_MAP.containsKey(value), "Can 
not find value `%s` in binlog event type", value);
+        return VALUE_AND_EVENT_TYPE_MAP.get(value);
     }
 }
diff --git 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLNewParametersBoundFlag.java
 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLNewParametersBoundFlag.java
index f29655e2e03..29919c2fc03 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLNewParametersBoundFlag.java
+++ 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLNewParametersBoundFlag.java
@@ -47,6 +47,6 @@ public enum MySQLNewParametersBoundFlag {
                 return each;
             }
         }
-        throw new IllegalArgumentException(String.format("Cannot find value 
'%s' in new parameters bound flag", value));
+        throw new IllegalArgumentException(String.format("Can not find value 
`%s` in new parameters bound flag", value));
     }
 }
diff --git 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLDateBinaryProtocolValue.java
 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLDateBinaryProtocolValue.java
index dde85c9716b..8552592fb65 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLDateBinaryProtocolValue.java
+++ 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLDateBinaryProtocolValue.java
@@ -45,7 +45,7 @@ public final class MySQLDateBinaryProtocolValue implements 
MySQLBinaryProtocolVa
                 result.setNanos(payload.readInt4() * 1000);
                 return result;
             default:
-                throw new IllegalArgumentException(String.format("Wrong length 
'%d' of MYSQL_TYPE_TIME", length));
+                throw new IllegalArgumentException(String.format("Wrong length 
`%d` of MYSQL_TYPE_TIME", length));
         }
     }
     
diff --git 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLTimeBinaryProtocolValue.java
 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLTimeBinaryProtocolValue.java
index 6b16b7dfeed..78e1e931c3c 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLTimeBinaryProtocolValue.java
+++ 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLTimeBinaryProtocolValue.java
@@ -43,7 +43,7 @@ public final class MySQLTimeBinaryProtocolValue implements 
MySQLBinaryProtocolVa
                 result.setNanos(payload.readInt4());
                 return result;
             default:
-                throw new IllegalArgumentException(String.format("Wrong length 
'%d' of MYSQL_TYPE_DATE", length));
+                throw new IllegalArgumentException(String.format("Wrong length 
`%d` of MYSQL_TYPE_DATE", length));
         }
     }
     
diff --git 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketType.java
 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketType.java
index 3a1158a605a..aab410480f4 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketType.java
+++ 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketType.java
@@ -73,7 +73,7 @@ public enum PostgreSQLCommandPacketType implements 
CommandPacketType, PostgreSQL
                 return each;
             }
         }
-        throw new IllegalArgumentException(String.format("Cannot find '%s' in 
PostgreSQL command packet type", value));
+        throw new IllegalArgumentException(String.format("Can not find `%s` in 
PostgreSQL command packet type", value));
     }
     
     /**
diff --git 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/PostgreSQLColumnType.java
 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/PostgreSQLColumnType.java
index 457031048a1..29569c738e3 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/PostgreSQLColumnType.java
+++ 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/PostgreSQLColumnType.java
@@ -17,6 +17,7 @@
 
 package 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended;
 
+import com.google.common.base.Preconditions;
 import lombok.Getter;
 import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.db.protocol.binary.BinaryColumnType;
@@ -183,10 +184,8 @@ public enum PostgreSQLColumnType implements 
BinaryColumnType {
      * @return PostgreSQL column type enum
      */
     public static PostgreSQLColumnType valueOfJDBCType(final int jdbcType) {
-        if (JDBC_TYPE_AND_COLUMN_TYPE_MAP.containsKey(jdbcType)) {
-            return JDBC_TYPE_AND_COLUMN_TYPE_MAP.get(jdbcType);
-        }
-        throw new IllegalArgumentException(String.format("Cannot find JDBC 
type '%s' in PostgreSQL column type", jdbcType));
+        
Preconditions.checkArgument(JDBC_TYPE_AND_COLUMN_TYPE_MAP.containsKey(jdbcType),
 "Can not find JDBC type `%s` in PostgreSQL column type", jdbcType);
+        return JDBC_TYPE_AND_COLUMN_TYPE_MAP.get(jdbcType);
     }
     
     /**
@@ -201,6 +200,6 @@ public enum PostgreSQLColumnType implements 
BinaryColumnType {
                 return each;
             }
         }
-        throw new IllegalArgumentException(String.format("Cannot find value 
'%s' in PostgreSQL column type", value));
+        throw new IllegalArgumentException(String.format("Can not find value 
`%s` in PostgreSQL column type", value));
     }
 }
diff --git 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLArrayParameterDecoder.java
 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLArrayParameterDecoder.java
index bd6f0b5eddf..7e43f83041b 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLArrayParameterDecoder.java
+++ 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLArrayParameterDecoder.java
@@ -17,6 +17,7 @@
 
 package 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol;
 
+import com.google.common.base.Preconditions;
 import 
org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.infra.util.exception.external.sql.type.generic.UnsupportedSQLOperationException;
 
@@ -168,12 +169,8 @@ public final class PostgreSQLArrayParameterDecoder {
      * @return decoded parameter value elements
      */
     private Collection<String> decodeText(final String value) {
-        if (value.length() < 2) {
-            throw new IllegalArgumentException("value length less than 2");
-        }
-        if ('{' != value.charAt(0) || '}' != value.charAt(value.length() - 1)) 
{
-            throw new IllegalArgumentException("value not start with '{' or 
not end with '}'");
-        }
+        Preconditions.checkArgument(value.length() >= 2, "value length less 
than 2");
+        Preconditions.checkArgument('{' == value.charAt(0) && '}' == 
value.charAt(value.length() - 1), "value not start with '{' or not end with 
'}'");
         String[] elements = value.substring(1, value.length() - 1).split(",");
         return Arrays.stream(elements).map(each -> {
             if ("NULL".equals(each)) {
diff --git 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLByteConverter.java
 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLByteConverter.java
index 032a802c676..7190ed7c216 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLByteConverter.java
+++ 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLByteConverter.java
@@ -74,8 +74,9 @@ public final class PostgreSQLByteConverter {
      */
     public static Number numeric(final byte[] bytes, final int pos) {
         short sign = readShort2(bytes, pos + 4);
+        Preconditions.checkArgument(0x0000 == sign || NUMERIC_NEG == sign || 
NUMERIC_NAN == sign, "invalid sign in \"numeric\" value");
         short scale = readShort2(bytes, pos + 6);
-        validator(sign, scale);
+        Preconditions.checkArgument((scale & 0x00003FFF) == scale, "invalid 
scale in \"numeric\" value");
         if (NUMERIC_NAN == sign) {
             return Double.NaN;
         }
@@ -358,15 +359,6 @@ public final class PostgreSQLByteConverter {
         return new BigDecimal(unscaledBI, scale);
     }
     
-    private static void validator(final short sign, final short scale) {
-        if (!(0x0000 == sign || NUMERIC_NEG == sign || NUMERIC_NAN == sign)) {
-            throw new IllegalArgumentException("invalid sign in \"numeric\" 
value");
-        }
-        if ((scale & 0x00003FFF) != scale) {
-            throw new IllegalArgumentException("invalid scale in \"numeric\" 
value");
-        }
-    }
-    
     private static BigInteger tenPower(final int exponent) {
         return BI_TEN_POWERS.length > exponent ? BI_TEN_POWERS[exponent] : 
BigInteger.TEN.pow(exponent);
     }
diff --git 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/identifier/PostgreSQLMessagePacketType.java
 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/identifier/PostgreSQLMessagePacketType.java
index 8ca21978d65..1bb7c08ee7e 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/identifier/PostgreSQLMessagePacketType.java
+++ 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/identifier/PostgreSQLMessagePacketType.java
@@ -103,6 +103,6 @@ public enum PostgreSQLMessagePacketType implements 
PostgreSQLIdentifierTag {
                 return each;
             }
         }
-        throw new IllegalArgumentException(String.format("Cannot find '%s' in 
PostgreSQL identifier tag type", value));
+        throw new IllegalArgumentException(String.format("Can not find `%s` in 
PostgreSQL identifier tag type", value));
     }
 }
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/complex/ComplexInlineShardingAlgorithm.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/complex/ComplexInlineShardingAlgorithm.java
index 773e0a51694..58bf57e3ba9 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/complex/ComplexInlineShardingAlgorithm.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/complex/ComplexInlineShardingAlgorithm.java
@@ -88,9 +88,8 @@ public final class ComplexInlineShardingAlgorithm implements 
ComplexKeysSharding
             return availableTargetNames;
         }
         Map<String, Collection<Comparable<?>>> columnNameAndShardingValuesMap 
= shardingValue.getColumnNameAndShardingValuesMap();
-        if (!shardingColumns.isEmpty() && shardingColumns.size() != 
columnNameAndShardingValuesMap.size()) {
-            throw new IllegalArgumentException("Complex inline need " + 
shardingColumns.size() + " sharing columns, but only found " + 
columnNameAndShardingValuesMap.size());
-        }
+        Preconditions.checkArgument(shardingColumns.isEmpty() || 
shardingColumns.size() == columnNameAndShardingValuesMap.size(),
+                "Complex inline need %s sharing columns, but only found %s", 
shardingColumns.size(), columnNameAndShardingValuesMap.size());
         Collection<Map<String, Comparable<?>>> combine = 
combine(columnNameAndShardingValuesMap);
         return 
combine.stream().map(this::doSharding).collect(Collectors.toList());
     }
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/datasource/state/DataSourceState.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/datasource/state/DataSourceState.java
index f25a4fca4dc..eae9e4a9164 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/datasource/state/DataSourceState.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/datasource/state/DataSourceState.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.infra.datasource.state;
 
+import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 
 import java.util.HashMap;
@@ -63,9 +64,7 @@ public enum DataSourceState {
      * @return data source state
      */
     public static DataSourceState getDataSourceState(final String state) {
-        if (!Strings.isNullOrEmpty(state) && 
DATA_SOURCE_STATES.containsKey(state.toLowerCase())) {
-            return DATA_SOURCE_STATES.get(state.toLowerCase());
-        }
-        throw new IllegalArgumentException("Illegal data source state: " + 
state);
+        Preconditions.checkArgument(!Strings.isNullOrEmpty(state) && 
DATA_SOURCE_STATES.containsKey(state.toLowerCase()), "Illegal data source state 
`%s`", state);
+        return DATA_SOURCE_STATES.get(state.toLowerCase());
     }
 }
diff --git 
a/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/yaml/constructor/ShardingSphereYamlConstructor.java
 
b/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/yaml/constructor/ShardingSphereYamlConstructor.java
index 1e22c0bd683..471379d306f 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/yaml/constructor/ShardingSphereYamlConstructor.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/yaml/constructor/ShardingSphereYamlConstructor.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.infra.util.yaml.constructor;
 
+import com.google.common.base.Preconditions;
 import 
org.apache.shardingsphere.infra.util.yaml.shortcuts.ShardingSphereYamlShortcutsFactory;
 import org.yaml.snakeyaml.TypeDescription;
 import org.yaml.snakeyaml.constructor.Construct;
@@ -49,9 +50,7 @@ public class ShardingSphereYamlConstructor extends 
Constructor {
     
     @Override
     protected Class<?> getClassForName(final String className) throws 
ClassNotFoundException {
-        if (className.equals(rootClass.getName())) {
-            return super.getClassForName(className);
-        }
-        throw new IllegalArgumentException(String.format("Class is not 
accepted: %s", className));
+        Preconditions.checkArgument(className.equals(rootClass.getName()), 
"Class `%s` is not accepted", className);
+        return super.getClassForName(className);
     }
 }
diff --git 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/PrimaryKeyPositionFactory.java
 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/PrimaryKeyPositionFactory.java
index 55647d6aef1..3ac18eba88a 100644
--- 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/PrimaryKeyPositionFactory.java
+++ 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/PrimaryKeyPositionFactory.java
@@ -58,10 +58,10 @@ public final class PrimaryKeyPositionFactory {
     public static IngestPosition<?> newInstance(final @NonNull Object 
beginValue, final @NonNull Object endValue) {
         if (beginValue instanceof Number) {
             return new IntegerPrimaryKeyPosition(((Number) 
beginValue).longValue(), ((Number) endValue).longValue());
-        } else if (beginValue instanceof CharSequence) {
+        }
+        if (beginValue instanceof CharSequence) {
             return new StringPrimaryKeyPosition(beginValue.toString(), 
endValue.toString());
-        } else {
-            throw new IllegalArgumentException("Unknown begin value type: " + 
beginValue.getClass().getName());
         }
+        throw new IllegalArgumentException("Unknown begin value type: " + 
beginValue.getClass().getName());
     }
 }
diff --git 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/config/process/PipelineProcessConfigurationUtil.java
 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/config/process/PipelineProcessConfigurationUtil.java
index 07b67b000cb..ec0cc6bef9a 100644
--- 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/config/process/PipelineProcessConfigurationUtil.java
+++ 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/config/process/PipelineProcessConfigurationUtil.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.data.pipeline.core.config.process;
 
+import com.google.common.base.Preconditions;
 import com.google.common.base.Splitter;
 import 
org.apache.shardingsphere.data.pipeline.api.config.process.PipelineProcessConfiguration;
 import 
org.apache.shardingsphere.data.pipeline.api.config.process.yaml.YamlPipelineProcessConfiguration;
@@ -83,9 +84,7 @@ public final class PipelineProcessConfigurationUtil {
      * @throws IllegalArgumentException if path doesn't match pattern
      */
     public static void verifyConfPath(final String confPath) {
-        if (!CONF_PATH_PATTERN.matcher(confPath).matches()) {
-            throw new IllegalArgumentException("Invalid confPath, it doesn't 
match pattern: " + CONF_PATH_REGEX);
-        }
+        
Preconditions.checkArgument(CONF_PATH_PATTERN.matcher(confPath).matches(), 
"Invalid confPath, it doesn't match pattern: %s", CONF_PATH_REGEX);
     }
     
     /**
diff --git 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/PipelineJobIdUtils.java
 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/PipelineJobIdUtils.java
index 955f00d8f4a..e6773a51cbb 100644
--- 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/PipelineJobIdUtils.java
+++ 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/PipelineJobIdUtils.java
@@ -18,12 +18,15 @@
 package org.apache.shardingsphere.data.pipeline.core.job;
 
 import com.google.common.base.Preconditions;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
 import org.apache.shardingsphere.data.pipeline.api.job.JobType;
 import org.apache.shardingsphere.data.pipeline.api.job.PipelineJobId;
 
 /**
  * Pipeline job id utils.
  */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
 public final class PipelineJobIdUtils {
     
     /**
@@ -41,15 +44,10 @@ public final class PipelineJobIdUtils {
      *
      * @param jobId job id
      * @return job type
-     * @throws IllegalArgumentException if job id is invalid
      */
     public static JobType parseJobType(final String jobId) {
-        if (jobId.length() <= 3) {
-            throw new IllegalArgumentException("Invalid jobId length, jobId=" 
+ jobId);
-        }
-        if ('j' != jobId.charAt(0)) {
-            throw new IllegalArgumentException("Invalid jobId, first char=" + 
jobId.charAt(0));
-        }
+        Preconditions.checkArgument(jobId.length() > 3, "Invalid jobId length, 
jobId=%s", jobId);
+        Preconditions.checkArgument('j' == jobId.charAt(0), "Invalid jobId, 
first char=%s", jobId.charAt(0));
         String typeCode = jobId.substring(1, 3);
         JobType result = JobType.valueOfByCode(typeCode);
         Preconditions.checkNotNull(result, "Can not get job type by `%s`, job 
ID is `%s`", typeCode, jobId);
diff --git 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/registry/CoordinatorRegistryCenterInitializer.java
 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/registry/CoordinatorRegistryCenterInitializer.java
index 8245184e5cd..7672bf70528 100644
--- 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/registry/CoordinatorRegistryCenterInitializer.java
+++ 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/registry/CoordinatorRegistryCenterInitializer.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.data.pipeline.core.registry;
 
+import com.google.common.base.Preconditions;
 import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
 import 
org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperConfiguration;
 import 
org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperRegistryCenter;
@@ -42,12 +43,10 @@ public final class CoordinatorRegistryCenterInitializer {
     public CoordinatorRegistryCenter createRegistryCenter(final 
ModeConfiguration modeConfig, final String namespaceRelativePath) {
         ClusterPersistRepositoryConfiguration repositoryConfig = 
(ClusterPersistRepositoryConfiguration) modeConfig.getRepository();
         String clusterType = modeConfig.getRepository().getType();
-        if ("ZooKeeper".equalsIgnoreCase(clusterType)) {
-            CoordinatorRegistryCenter result = new 
ZookeeperRegistryCenter(getZookeeperConfig(repositoryConfig, 
namespaceRelativePath));
-            result.init();
-            return result;
-        }
-        throw new IllegalArgumentException("Unsupported clusterType=" + 
clusterType);
+        Preconditions.checkArgument("ZooKeeper".equalsIgnoreCase(clusterType), 
"Unsupported cluster type `%s`", clusterType);
+        CoordinatorRegistryCenter result = new 
ZookeeperRegistryCenter(getZookeeperConfig(repositoryConfig, 
namespaceRelativePath));
+        result.init();
+        return result;
     }
     
     // TODO Merge registry center code in ElasticJob and ShardingSphere mode; 
Use spi to load impl;
@@ -69,8 +68,7 @@ public final class CoordinatorRegistryCenterInitializer {
         if (0 != operationTimeoutMilliseconds) {
             
result.setConnectionTimeoutMilliseconds(operationTimeoutMilliseconds);
         }
-        String digest = zookeeperProps.getValue(ZookeeperPropertyKey.DIGEST);
-        result.setDigest(digest);
+        result.setDigest(zookeeperProps.getValue(ZookeeperPropertyKey.DIGEST));
         return result;
     }
 }
diff --git 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/AbstractPipelineSQLBuilder.java
 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/AbstractPipelineSQLBuilder.java
index dca4aefb36a..30755cd1c4b 100644
--- 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/AbstractPipelineSQLBuilder.java
+++ 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/AbstractPipelineSQLBuilder.java
@@ -81,12 +81,11 @@ public abstract class AbstractPipelineSQLBuilder implements 
PipelineSQLBuilder {
         if (PipelineJdbcUtils.isIntegerColumn(uniqueKeyDataType)) {
             return "SELECT * FROM " + decoratedTableName + " WHERE " + 
quotedUniqueKey + " " + (firstQuery ? ">=" : ">") + " ?"
                     + " AND " + quotedUniqueKey + " <= ? ORDER BY " + 
quotedUniqueKey + " ASC LIMIT ?";
-        } else if (PipelineJdbcUtils.isStringColumn(uniqueKeyDataType)) {
-            return "SELECT * FROM " + decoratedTableName + " WHERE " + 
quotedUniqueKey + " " + (firstQuery ? ">=" : ">") + " ?"
-                    + " ORDER BY " + quotedUniqueKey + " ASC LIMIT ?";
-        } else {
-            throw new IllegalArgumentException("Unknown uniqueKeyDataType: " + 
uniqueKeyDataType);
         }
+        if (PipelineJdbcUtils.isStringColumn(uniqueKeyDataType)) {
+            return "SELECT * FROM " + decoratedTableName + " WHERE " + 
quotedUniqueKey + " " + (firstQuery ? ">=" : ">") + " ?" + " ORDER BY " + 
quotedUniqueKey + " ASC LIMIT ?";
+        }
+        throw new IllegalArgumentException("Unknown uniqueKeyDataType: " + 
uniqueKeyDataType);
     }
     
     protected String decorate(final String schemaName, final String tableName) 
{
diff --git 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/OraclePipelineSQLBuilder.java
 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/OraclePipelineSQLBuilder.java
index 6bf160cf5bb..bb9ea68c4b0 100644
--- 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/OraclePipelineSQLBuilder.java
+++ 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/OraclePipelineSQLBuilder.java
@@ -53,12 +53,12 @@ public final class OraclePipelineSQLBuilder extends 
AbstractPipelineSQLBuilder {
         if (PipelineJdbcUtils.isIntegerColumn(uniqueKeyDataType)) {
             return "SELECT * FROM (SELECT * FROM " + decoratedTableName + " 
WHERE " + quotedUniqueKey + " " + (firstQuery ? ">=" : ">") + " ?"
                     + " AND " + quotedUniqueKey + " <= ? ORDER BY " + 
quotedUniqueKey + " ASC) WHERE ROWNUM<=?";
-        } else if (PipelineJdbcUtils.isStringColumn(uniqueKeyDataType)) {
+        }
+        if (PipelineJdbcUtils.isStringColumn(uniqueKeyDataType)) {
             return "SELECT * FROM (SELECT * FROM " + decoratedTableName + " 
WHERE " + quotedUniqueKey + " " + (firstQuery ? ">=" : ">") + " ?"
                     + " ORDER BY " + quotedUniqueKey + " ASC) WHERE ROWNUM<=?";
-        } else {
-            throw new IllegalArgumentException("Unknown uniqueKeyDataType: " + 
uniqueKeyDataType);
         }
+        throw new IllegalArgumentException("Unknown uniqueKeyDataType: " + 
uniqueKeyDataType);
     }
     
     @Override
@@ -70,11 +70,9 @@ public final class OraclePipelineSQLBuilder extends 
AbstractPipelineSQLBuilder {
     
     @Override
     public String buildChunkedQuerySQL(final String schemaName, final @NonNull 
String tableName, final @NonNull String uniqueKey, final boolean firstQuery) {
-        if (firstQuery) {
-            return "SELECT * FROM (SELECT * FROM " + decorate(schemaName, 
tableName) + " ORDER BY " + quote(uniqueKey) + " ASC) WHERE ROWNUM<=?";
-        } else {
-            return "SELECT * FROM (SELECT * FROM " + decorate(schemaName, 
tableName) + " WHERE " + quote(uniqueKey) + " > ? ORDER BY " + quote(uniqueKey) 
+ " ASC) WHERE ROWNUM<=?";
-        }
+        return firstQuery
+                ? "SELECT * FROM (SELECT * FROM " + decorate(schemaName, 
tableName) + " ORDER BY " + quote(uniqueKey) + " ASC) WHERE ROWNUM<=?"
+                : "SELECT * FROM (SELECT * FROM " + decorate(schemaName, 
tableName) + " WHERE " + quote(uniqueKey) + " > ? ORDER BY " + quote(uniqueKey) 
+ " ASC) WHERE ROWNUM<=?";
     }
     
     @Override
diff --git 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-opengauss/src/main/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/wal/decode/MppdbDecodingPlugin.java
 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-opengauss/src/main/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/wal/decode/MppdbDecodingPlugin.java
index 9f26639ca49..8cf99a80be3 100644
--- 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-opengauss/src/main/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/wal/decode/MppdbDecodingPlugin.java
+++ 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-opengauss/src/main/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/wal/decode/MppdbDecodingPlugin.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.data.pipeline.opengauss.ingest.wal.decode;
 
+import com.google.common.base.Preconditions;
 import com.google.gson.Gson;
 import lombok.AllArgsConstructor;
 import 
org.apache.shardingsphere.data.pipeline.core.ingest.IngestDataChangeType;
@@ -242,9 +243,7 @@ public final class MppdbDecodingPlugin implements 
DecodingPlugin {
     
     private static byte[] decodeHex(final String hexString) {
         int dataLength = hexString.length();
-        if (0 != (dataLength & 1)) {
-            throw new IllegalArgumentException(String.format("Illegal hex data 
%s", hexString));
-        }
+        Preconditions.checkArgument(0 == (dataLength & 1), "Illegal hex data 
`%s`", hexString);
         if (0 == dataLength) {
             return new byte[0];
         }
@@ -258,9 +257,7 @@ public final class MppdbDecodingPlugin implements 
DecodingPlugin {
     private static byte decodeHexByte(final String hexString, final int index) 
{
         int firstHexChar = Character.digit(hexString.charAt(index), 16);
         int secondHexChar = Character.digit(hexString.charAt(index + 1), 16);
-        if (-1 == firstHexChar || -1 == secondHexChar) {
-            throw new IllegalArgumentException(String.format("Illegal hex byte 
'%s' in index %d", hexString, index));
-        }
+        Preconditions.checkArgument(-1 != firstHexChar && -1 != secondHexChar, 
"Illegal hex byte `%s` in index `%d`", hexString, index);
         return (byte) ((firstHexChar << 4) + secondHexChar);
     }
 }
diff --git 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/decode/TestDecodingPlugin.java
 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/decode/TestDecodingPlugin.java
index 659ac24ba8b..e4e81fcf402 100644
--- 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/decode/TestDecodingPlugin.java
+++ 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/decode/TestDecodingPlugin.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.data.pipeline.postgresql.ingest.wal.decode;
 
+import com.google.common.base.Preconditions;
 import lombok.AllArgsConstructor;
 import 
org.apache.shardingsphere.data.pipeline.core.ingest.IngestDataChangeType;
 import 
org.apache.shardingsphere.data.pipeline.core.ingest.exception.IngestException;
@@ -236,9 +237,7 @@ public final class TestDecodingPlugin implements 
DecodingPlugin {
     
     private byte[] decodeHex(final String hexString) {
         int dataLength = hexString.length();
-        if (0 != (dataLength & 1)) {
-            throw new IllegalArgumentException(String.format("Illegal hex data 
%s", hexString));
-        }
+        Preconditions.checkArgument(0 == (dataLength & 1), "Illegal hex data 
`%s`", hexString);
         if (0 == dataLength) {
             return new byte[0];
         }
@@ -252,9 +251,7 @@ public final class TestDecodingPlugin implements 
DecodingPlugin {
     private byte decodeHexByte(final String hexString, final int index) {
         int firstHexChar = Character.digit(hexString.charAt(index), 16);
         int secondHexChar = Character.digit(hexString.charAt(index + 1), 16);
-        if (-1 == firstHexChar || -1 == secondHexChar) {
-            throw new IllegalArgumentException(String.format("Illegal hex byte 
'%s' in index %d", hexString, index));
-        }
+        Preconditions.checkArgument(-1 != firstHexChar && -1 != secondHexChar, 
"Illegal hex byte `%s` in index `%d`", hexString, index);
         return (byte) ((firstHexChar << 4) + secondHexChar);
     }
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationHandler.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationHandler.java
index 8f3cff5e1e3..cf51f096436 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationHandler.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationHandler.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.proxy.frontend.opengauss.authentication;
 
+import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
@@ -167,9 +168,7 @@ public final class OpenGaussAuthenticationHandler {
     }
     
     private static byte[] xor(final byte[] password1, final byte[] password2) {
-        if (password1.length != password2.length) {
-            throw new IllegalArgumentException("Xor values with different 
length");
-        }
+        Preconditions.checkArgument(password1.length == password2.length, "Xor 
values with different length");
         int length = password1.length;
         byte[] result = new byte[length];
         for (int i = 0; i < length; i++) {
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/cases/dataset/DataSet.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/cases/dataset/DataSet.java
index c1a37dbf030..050716d15c5 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/cases/dataset/DataSet.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/cases/dataset/DataSet.java
@@ -55,10 +55,7 @@ public final class DataSet {
      */
     public DataSetMetaData findMetaData(final String tableName) {
         Optional<DataSetMetaData> result = metaDataList.stream().filter(each 
-> tableName.equals(each.getTableName())).findFirst();
-        if (result.isPresent()) {
-            return result.get();
-        }
-        throw new IllegalArgumentException(String.format("Cannot find expected 
metadata via table name: '%s'", tableName));
+        return result.orElseThrow(() -> new 
IllegalArgumentException(String.format("Can not find expected meta data via 
table `%s`", tableName)));
     }
     
     /**
@@ -69,10 +66,7 @@ public final class DataSet {
      */
     public DataSetMetaData findMetaData(final DataNode dataNode) {
         Optional<DataSetMetaData> result = metaDataList.stream().filter(each 
-> contains(new InlineExpressionParser(each.getDataNodes()).splitAndEvaluate(), 
dataNode)).findFirst();
-        if (result.isPresent()) {
-            return result.get();
-        }
-        throw new IllegalArgumentException(String.format("Cannot find data 
node: %s", dataNode));
+        return result.orElseThrow(() -> new 
IllegalArgumentException(String.format("Cannot find data node: %s", dataNode)));
     }
     
     private boolean contains(final List<String> dataNodes, final DataNode 
dataNode) {
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/cases/dataset/DataSetLoader.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/cases/dataset/DataSetLoader.java
index 27ed1a59e74..d086e61993c 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/cases/dataset/DataSetLoader.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/cases/dataset/DataSetLoader.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.test.integration.cases.dataset;
 
+import com.google.common.base.Preconditions;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import lombok.SneakyThrows;
@@ -67,9 +68,7 @@ public final class DataSetLoader {
             return result;
         }
         result = String.join(File.separator, parentPath, DATA_SET_FOLDER_NAME, 
dataSetFile);
-        if (new File(result).exists()) {
-            return result;
-        }
-        throw new IllegalArgumentException(String.format("%s not found, 
path=%s, scenario=%s, databaseType=%s, mode=%s", dataSetFile, parentPath, 
scenario, databaseType.getType(), mode));
+        Preconditions.checkArgument(new File(result).exists(), "%s not found, 
path=%s, scenario=%s, databaseType=%s, mode=%s", dataSetFile, parentPath, 
scenario, databaseType.getType(), mode);
+        return result;
     }
 }
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/sql/loader/SQLCasesLoader.java
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/sql/loader/SQLCasesLoader.java
index 1deae0271e4..d91690fe019 100644
--- 
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/sql/loader/SQLCasesLoader.java
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/sql/loader/SQLCasesLoader.java
@@ -165,10 +165,7 @@ public final class SQLCasesLoader extends CasesLoader {
     }
     
     private static void appendReplacement(final int markerIndex, final 
Object[] replacements, final Matcher matcher, final StringBuffer buffer) {
-        if (markerIndex > replacements.length) {
-            throw new IllegalArgumentException(
-                    String.format("Missing replacement for '%s' at [%s].", 
PARAMETER_MARKER.pattern(), markerIndex));
-        }
+        Preconditions.checkArgument(markerIndex <= replacements.length, 
"Missing replacement for `%s` at index `%s`", PARAMETER_MARKER.pattern(), 
markerIndex);
         matcher.appendReplacement(buffer, 
Matcher.quoteReplacement(replacements[markerIndex - 1].toString()));
     }
 }
diff --git 
a/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/scenario/EncryptSQLRewriterParameterizedTest.java
 
b/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/scenario/EncryptSQLRewriterParameterizedTest.java
index d67db979be2..93469f02c90 100644
--- 
a/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/scenario/EncryptSQLRewriterParameterizedTest.java
+++ 
b/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/scenario/EncryptSQLRewriterParameterizedTest.java
@@ -65,7 +65,7 @@ public final class EncryptSQLRewriterParameterizedTest 
extends AbstractSQLRewrit
     @Override
     protected YamlRootConfiguration createRootConfiguration() throws 
IOException {
         URL url = 
EncryptSQLRewriterParameterizedTest.class.getClassLoader().getResource(getTestParameters().getRuleFile());
-        Preconditions.checkNotNull(url, "Cannot found rewrite rule yaml 
configuration.");
+        Preconditions.checkNotNull(url, "Can not find rewrite rule yaml 
configuration");
         return YamlEngine.unmarshal(new File(url.getFile()), 
YamlRootConfiguration.class);
     }
     
diff --git 
a/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/scenario/MixSQLRewriterParameterizedTest.java
 
b/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/scenario/MixSQLRewriterParameterizedTest.java
index 9cdfc6ef3f7..efdf1db2919 100644
--- 
a/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/scenario/MixSQLRewriterParameterizedTest.java
+++ 
b/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/scenario/MixSQLRewriterParameterizedTest.java
@@ -61,7 +61,7 @@ public final class MixSQLRewriterParameterizedTest extends 
AbstractSQLRewriterPa
     @Override
     protected YamlRootConfiguration createRootConfiguration() throws 
IOException {
         URL url = 
MixSQLRewriterParameterizedTest.class.getClassLoader().getResource(getTestParameters().getRuleFile());
-        Preconditions.checkNotNull(url, "Cannot found rewrite rule yaml 
configurations.");
+        Preconditions.checkNotNull(url, "Can not find rewrite rule yaml 
configurations");
         return YamlEngine.unmarshal(new File(url.getFile()), 
YamlRootConfiguration.class);
     }
     
diff --git 
a/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/scenario/ShardingSQLRewriterParameterizedTest.java
 
b/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/scenario/ShardingSQLRewriterParameterizedTest.java
index 9509ef269a3..68348ad9195 100644
--- 
a/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/scenario/ShardingSQLRewriterParameterizedTest.java
+++ 
b/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/scenario/ShardingSQLRewriterParameterizedTest.java
@@ -64,7 +64,7 @@ public final class ShardingSQLRewriterParameterizedTest 
extends AbstractSQLRewri
     @Override
     protected YamlRootConfiguration createRootConfiguration() throws 
IOException {
         URL url = 
ShardingSQLRewriterParameterizedTest.class.getClassLoader().getResource(getTestParameters().getRuleFile());
-        Preconditions.checkNotNull(url, "Cannot found rewrite rule yaml 
configuration.");
+        Preconditions.checkNotNull(url, "Can not find rewrite rule yaml 
configuration");
         return YamlEngine.unmarshal(new File(url.getFile()), 
YamlRootConfiguration.class);
     }
     

Reply via email to