You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by yx...@apache.org on 2022/09/12 14:21:01 UTC
[shardingsphere] branch master updated: Rewrite `== 0` to `0 ==` (#20940)
This is an automated email from the ASF dual-hosted git repository.
yx9o 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 dc757406bb6 Rewrite `== 0` to `0 ==` (#20940)
dc757406bb6 is described below
commit dc757406bb628d9877228e338de25863b92be66f
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Mon Sep 12 22:20:51 2022 +0800
Rewrite `== 0` to `0 ==` (#20940)
---
.../service/OrderStatisticsInfoServiceImpl.java | 2 +-
.../example/generator/core/GenerateUtil.java | 4 +-
.../metrics/prometheus/util/ReflectiveUtil.java | 2 +-
.../decimal/MySQLDecimalBinlogProtocolValue.java | 2 +-
.../string/MySQLStringBinlogProtocolValue.java | 2 +-
.../command/MySQLCommandPacketTypeLoader.java | 2 +-
.../packet/handshake/MySQLHandshakePacket.java | 2 +-
.../value/string/MySQLJsonValueDecoderTest.java | 2 +-
.../bind/protocol/PostgreSQLByteConverter.java | 40 +++++++--------
.../generator/EncryptAlterTableTokenGenerator.java | 2 +-
.../encrypt/sm/algorithm/SM3EncryptAlgorithm.java | 4 +-
...ReplicaWeightReadQueryLoadBalanceAlgorithm.java | 5 +-
...sactionWeightReadQueryLoadBalanceAlgorithm.java | 5 +-
.../sharding/mod/ModShardingAlgorithm.java | 2 +-
.../handler/AuthorityRuleQueryResultSet.java | 2 +-
...StreamingDataConsistencyCalculateAlgorithm.java | 2 +-
.../core/ingest/channel/memory/ManualBitSet.java | 4 +-
.../core/prepare/InventoryTaskSplitter.java | 4 +-
.../ingest/wal/decode/MppdbDecodingPlugin.java | 2 +-
.../PostgresConstraintsPropertiesAppender.java | 8 +--
.../repository/standalone/jdbc/JDBCRepository.java | 2 +-
.../visitor/format/impl/MySQLFormatSQLVisitor.java | 12 ++---
.../env/container/atomic/util/CommandPartUtil.java | 57 ----------------------
.../pipeline/cases/task/MySQLIncrementTask.java | 6 +--
.../cases/task/PostgreSQLIncrementTask.java | 6 +--
25 files changed, 59 insertions(+), 122 deletions(-)
diff --git a/examples/example-core/example-raw-jdbc/src/main/java/org/apache/shardingsphere/example/core/jdbc/service/OrderStatisticsInfoServiceImpl.java b/examples/example-core/example-raw-jdbc/src/main/java/org/apache/shardingsphere/example/core/jdbc/service/OrderStatisticsInfoServiceImpl.java
index d54b059a582..b148976c165 100644
--- a/examples/example-core/example-raw-jdbc/src/main/java/org/apache/shardingsphere/example/core/jdbc/service/OrderStatisticsInfoServiceImpl.java
+++ b/examples/example-core/example-raw-jdbc/src/main/java/org/apache/shardingsphere/example/core/jdbc/service/OrderStatisticsInfoServiceImpl.java
@@ -78,7 +78,7 @@ public final class OrderStatisticsInfoServiceImpl implements ExampleService {
private OrderStatisticsInfo insertOrderStatisticsInfo(final int i) throws SQLException {
OrderStatisticsInfo result = new OrderStatisticsInfo();
result.setUserId(new Long(i));
- if (i % 2 == 0) {
+ if (0 == i % 2) {
result.setOrderDate(LocalDate.now().plusYears(-1));
} else {
result.setOrderDate(LocalDate.now());
diff --git a/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/GenerateUtil.java b/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/GenerateUtil.java
index 11bc92a5b2c..00eed7e507e 100644
--- a/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/GenerateUtil.java
+++ b/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/GenerateUtil.java
@@ -52,7 +52,7 @@ public final class GenerateUtil {
*/
@SuppressWarnings("ResultOfMethodCallIgnored")
public static void generateDirs(final Configuration templateConfig, final Map<String, String> dataModel, final Collection<String> paths, final String outputPath) throws IOException, TemplateException {
- if (null == paths || 0 == paths.size()) {
+ if (null == paths || paths.isEmpty()) {
new File(generatePath(templateConfig, dataModel, outputPath)).mkdirs();
return;
}
@@ -123,7 +123,7 @@ public final class GenerateUtil {
for (int i = 0, size = 1 << len; i < size; i++) {
StringBuilder eachCombBuilder = new StringBuilder();
for (int j = 0; j < len; j++) {
- if (((1 << j) & i) != 0) {
+ if (0 != ((1 << j) & i)) {
eachCombBuilder.append(combinations.get(j)).append(",");
}
}
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/util/ReflectiveUtil.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/util/ReflectiveUtil.java
index 7127fc62b72..9166528c505 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/util/ReflectiveUtil.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/util/ReflectiveUtil.java
@@ -55,6 +55,6 @@ public final class ReflectiveUtil {
private static Field getField(final Class<?> clazz, final String fieldName) {
Field[] fields = clazz.getDeclaredFields();
- return fields.length != 0 ? Arrays.stream(fields).filter(each -> fieldName.equals(each.getName())).findFirst().orElse(null) : null;
+ return 0 == fields.length ? null : Arrays.stream(fields).filter(each -> fieldName.equals(each.getName())).findFirst().orElse(null);
}
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/decimal/MySQLDecimalBinlogProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/decimal/MySQLDecimalBinlogProtocolValue.java
index 3bdae5d9841..55055dd28f5 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/decimal/MySQLDecimalBinlogProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/decimal/MySQLDecimalBinlogProtocolValue.java
@@ -45,7 +45,7 @@ public final class MySQLDecimalBinlogProtocolValue implements MySQLBinlogProtoco
}
private static BigDecimal toDecimal(final DecimalMetaData metaData, final byte[] value) {
- boolean positive = (value[0] & 0x80) == 0x80;
+ boolean positive = 0x80 == (value[0] & 0x80);
value[0] ^= 0x80;
if (!positive) {
for (int i = 0; i < value.length; i++) {
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValue.java
index b4265d33712..732ab5580f7 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValue.java
@@ -35,7 +35,7 @@ public final class MySQLStringBinlogProtocolValue implements MySQLBinlogProtocol
int type = columnDef.getColumnMeta() >> 8;
int length = columnDef.getColumnMeta() & 0xff;
// unpack type & length, see https://bugs.mysql.com/bug.php?id=37426.
- if ((type & 0x30) != 0x30) {
+ if (0x30 != (type & 0x30)) {
length += ((type & 0x30) ^ 0x30) << 4;
type |= 0x30;
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/MySQLCommandPacketTypeLoader.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/MySQLCommandPacketTypeLoader.java
index c03543aaeb8..47cdb3e63ea 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/MySQLCommandPacketTypeLoader.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/MySQLCommandPacketTypeLoader.java
@@ -35,7 +35,7 @@ public final class MySQLCommandPacketTypeLoader {
* @return command packet type for MySQL
*/
public static MySQLCommandPacketType getCommandPacketType(final MySQLPacketPayload payload) {
- Preconditions.checkArgument(0 == payload.readInt1(), "Sequence ID of MySQL command packet must be `0`.");
+ Preconditions.checkArgument(0 == payload.readInt1(), "Sequence ID of MySQL command packet must be `0`");
return MySQLCommandPacketType.valueOf(payload.readInt1());
}
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/handshake/MySQLHandshakePacket.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/handshake/MySQLHandshakePacket.java
index 63fcd344007..07372b69bf5 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/handshake/MySQLHandshakePacket.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/handshake/MySQLHandshakePacket.java
@@ -64,7 +64,7 @@ public final class MySQLHandshakePacket implements MySQLPacket {
}
public MySQLHandshakePacket(final MySQLPacketPayload payload) {
- Preconditions.checkArgument(0 == payload.readInt1(), "Sequence ID of MySQL handshake packet must be `0`.");
+ Preconditions.checkArgument(0 == payload.readInt1(), "Sequence ID of MySQL handshake packet must be `0`");
Preconditions.checkArgument(protocolVersion == payload.readInt1());
serverVersion = payload.readStringNul();
connectionId = payload.readInt4();
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonValueDecoderTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonValueDecoderTest.java
index a83c41f3889..cc78b58dc24 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonValueDecoderTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonValueDecoderTest.java
@@ -364,7 +364,7 @@ public final class MySQLJsonValueDecoderTest {
}
private byte[] codecDataLength(final int length) {
- byte[] lengthData = new byte[32 / 7 + (32 % 7 == 0 ? 0 : 1)];
+ byte[] lengthData = new byte[32 / 7 + (0 == 32 % 7 ? 0 : 1)];
for (int i = 0; i < lengthData.length; i++) {
lengthData[i] = (byte) ((length >> (7 * i)) & 0x7f);
}
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 751d7eed635..032a802c676 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
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol;
+import com.google.common.base.Preconditions;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -75,22 +76,19 @@ public final class PostgreSQLByteConverter {
short sign = readShort2(bytes, pos + 4);
short scale = readShort2(bytes, pos + 6);
validator(sign, scale);
- if (sign == NUMERIC_NAN) {
+ if (NUMERIC_NAN == sign) {
return Double.NaN;
}
short len = readShort2(bytes, pos);
- if (len == 0) {
+ if (0 == len) {
return new BigDecimal(BigInteger.ZERO, scale);
}
short weight = readShort2(bytes, pos + 2);
if (weight < 0) {
++weight;
return initBigDecimalNoneWeight(bytes, pos, len, weight, sign, scale);
- } else if (scale == 0) {
- return initBigDecimalNoneScale(bytes, pos, len, weight, sign);
- } else {
- return initBigDecimal(bytes, pos, len, weight, sign, scale);
}
+ return 0 == scale ? initBigDecimalNoneScale(bytes, pos, len, weight, sign) : initBigDecimal(bytes, pos, len, weight, sign, scale);
}
/**
@@ -114,7 +112,7 @@ public final class PostgreSQLByteConverter {
unscaled = unscaled.multiply(tenPower(mod));
scale = 0;
}
- if (scale == 0) {
+ if (0 == scale) {
weight = initShortValuesNoneScaled(shortStacks, unscaled, weight);
} else {
weight = initShortValuesScaled(shortStacks, unscaled, scale);
@@ -133,7 +131,7 @@ public final class PostgreSQLByteConverter {
BigInteger tempUnscaled = unscaled;
BigInteger maxInteger = BigInteger.valueOf(Long.MAX_VALUE);
while (unscaled.compareTo(maxInteger) > 0) {
- final BigInteger[] pair = unscaled.divideAndRemainder(BI_TEN_THOUSAND);
+ BigInteger[] pair = unscaled.divideAndRemainder(BI_TEN_THOUSAND);
tempUnscaled = pair[0];
shortStacks.push(pair[1].shortValue());
++result;
@@ -143,7 +141,7 @@ public final class PostgreSQLByteConverter {
shortStacks.push((short) (unscaledLong % 10000));
unscaledLong = unscaledLong / 10000L;
++result;
- } while (unscaledLong != 0);
+ } while (0 != unscaledLong);
return result;
}
@@ -155,7 +153,7 @@ public final class PostgreSQLByteConverter {
if (!BigInteger.ZERO.equals(decimal)) {
int mod = scale % 4;
int segments = scale / 4;
- if (mod != 0) {
+ if (0 != mod) {
decimal = decimal.multiply(tenPower(4 - mod));
++segments;
}
@@ -214,7 +212,7 @@ public final class PostgreSQLByteConverter {
if (weight < 0) {
effectiveScale += 4 * weight;
}
- for (int i = 1; i < len && d == 0; ++i) {
+ for (int i = 1; i < len && 0 == d; ++i) {
effectiveScale -= 4;
idx += 2;
d = readShort2(bytes, idx);
@@ -253,7 +251,7 @@ public final class PostgreSQLByteConverter {
if (null == unscaledBI) {
unscaledInt += d;
} else {
- if (d != 0) {
+ if (0 != d) {
unscaledBI = unscaledBI.add(BigInteger.valueOf(d));
}
}
@@ -286,7 +284,7 @@ public final class PostgreSQLByteConverter {
unscaledInt += d;
} else {
unscaledBI = unscaledBI.multiply(BI_TEN_THOUSAND);
- if (d != 0) {
+ if (0 != d) {
unscaledBI = unscaledBI.add(BigInteger.valueOf(d));
}
}
@@ -298,7 +296,7 @@ public final class PostgreSQLByteConverter {
unscaledBI = unscaledBI.negate();
}
final int bigDecScale = (len - (weight + 1)) * 4;
- return bigDecScale == 0 ? new BigDecimal(unscaledBI) : new BigDecimal(unscaledBI, bigDecScale);
+ return 0 == bigDecScale ? new BigDecimal(unscaledBI) : new BigDecimal(unscaledBI, bigDecScale);
}
private static Number initBigDecimal(final byte[] bytes, final int pos, final short len, final short weight, final short sign, final short scale) {
@@ -340,7 +338,7 @@ public final class PostgreSQLByteConverter {
if (null == unscaledBI) {
unscaledInt += d;
} else {
- if (d != 0) {
+ if (0 != d) {
unscaledBI = unscaledBI.add(BigInteger.valueOf(d));
}
}
@@ -354,14 +352,14 @@ public final class PostgreSQLByteConverter {
if (effectiveScale > 0) {
unscaledBI = unscaledBI.multiply(tenPower(effectiveScale));
}
- if (sign == NUMERIC_NEG) {
+ if (NUMERIC_NEG == sign) {
unscaledBI = unscaledBI.negate();
}
return new BigDecimal(unscaledBI, scale);
}
private static void validator(final short sign, final short scale) {
- if (!(sign == 0x0000 || NUMERIC_NEG == sign || NUMERIC_NAN == sign)) {
+ if (!(0x0000 == sign || NUMERIC_NEG == sign || NUMERIC_NAN == sign)) {
throw new IllegalArgumentException("invalid sign in \"numeric\" value");
}
if ((scale & 0x00003FFF) != scale) {
@@ -387,10 +385,8 @@ public final class PostgreSQLByteConverter {
private int index;
public void push(final short value) {
- if (value != 0 || index != 0) {
- if (value < 0) {
- throw new IllegalArgumentException("only non-negative values accepted: " + value);
- }
+ if (0 != value || 0 != index) {
+ Preconditions.checkArgument(value >= 0, "only non-negative values accepted: %s", value);
if (index == shorts.length) {
grow();
}
@@ -403,7 +399,7 @@ public final class PostgreSQLByteConverter {
}
public boolean isEmpty() {
- return index == 0;
+ return 0 == index;
}
public short pop() {
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptAlterTableTokenGenerator.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptAlterTableTokenGenerator.java
index 857397057fe..c1912fb101a 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptAlterTableTokenGenerator.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptAlterTableTokenGenerator.java
@@ -84,7 +84,7 @@ public final class EncryptAlterTableTokenGenerator implements CollectionSQLToken
for (int i = 0; i < dropSQLTokens.size(); i++) {
SQLToken token = ((List<SQLToken>) dropSQLTokens).get(i);
if (token instanceof RemoveToken) {
- if (i != 0) {
+ if (0 != i) {
result.add(new RemoveToken(lastStartIndex, ((RemoveToken) token).getStopIndex()));
} else {
result.add(token);
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-plugin/shardingsphere-encrypt-sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithm.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-plugin/shardingsphere-encrypt-sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithm.java
index a08fdfba433..4576762df6c 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-plugin/shardingsphere-encrypt-sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-plugin/shardingsphere-encrypt-sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithm.java
@@ -55,8 +55,8 @@ public final class SM3EncryptAlgorithm implements EncryptAlgorithm<Object, Strin
private byte[] createSm3Salt(final Properties props) {
String salt = null == props.getProperty(SM3_SALT) ? "" : String.valueOf(props.getProperty(SM3_SALT));
- Preconditions.checkState(0 == salt.length() || SALT_LENGTH == salt.length(), "Salt should be either blank or better " + SALT_LENGTH + " bytes long.");
- return 0 == salt.length() ? new byte[0] : salt.getBytes(StandardCharsets.UTF_8);
+ Preconditions.checkState(salt.isEmpty() || SALT_LENGTH == salt.length(), "Salt should be either blank or better " + SALT_LENGTH + " bytes long.");
+ return salt.isEmpty() ? new byte[0] : salt.getBytes(StandardCharsets.UTF_8);
}
@Override
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/FixedReplicaWeightReadQueryLoadBalanceAlgorithm.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/FixedReplicaWeightReadQueryLoadBalanceAlgorithm.java
index a349870213e..ac4eff04437 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/FixedReplicaWeightReadQueryLoadBalanceAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/FixedReplicaWeightReadQueryLoadBalanceAlgorithm.java
@@ -70,9 +70,8 @@ public final class FixedReplicaWeightReadQueryLoadBalanceAlgorithm implements Re
private double[] initWeight(final List<String> readDataSourceNames) {
double[] result = getWeights(readDataSourceNames);
- if (result.length != 0 && Math.abs(result[result.length - 1] - 1.0D) >= ACCURACY_THRESHOLD) {
- throw new IllegalStateException("The cumulative weight is calculated incorrectly, and the sum of the probabilities is not equal to 1.");
- }
+ Preconditions.checkState(0 == result.length || !(Math.abs(result[result.length - 1] - 1.0D) >= ACCURACY_THRESHOLD),
+ "The cumulative weight is calculated incorrectly, and the sum of the probabilities is not equal to 1");
return result;
}
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/TransactionWeightReadQueryLoadBalanceAlgorithm.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/TransactionWeightReadQueryLoadBalanceAlgorithm.java
index 8975b2e0fb2..d888ede2a0c 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/TransactionWeightReadQueryLoadBalanceAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/TransactionWeightReadQueryLoadBalanceAlgorithm.java
@@ -64,9 +64,8 @@ public final class TransactionWeightReadQueryLoadBalanceAlgorithm implements Rea
private double[] initWeight(final List<String> readDataSourceNames) {
double[] result = getWeights(readDataSourceNames);
- if (result.length != 0 && Math.abs(result[result.length - 1] - 1.0D) >= ACCURACY_THRESHOLD) {
- throw new IllegalStateException("The cumulative weight is calculated incorrectly, and the sum of the probabilities is not equal to 1.");
- }
+ Preconditions.checkState(0 == result.length || !(Math.abs(result[result.length - 1] - 1.0D) >= ACCURACY_THRESHOLD),
+ "The cumulative weight is calculated incorrectly, and the sum of the probabilities is not equal to 1");
return result;
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithm.java
index 70329bcf2c6..3baf064db10 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithm.java
@@ -85,7 +85,7 @@ public final class ModShardingAlgorithm implements StandardShardingAlgorithm<Com
private int calculateMaxPaddingSize() {
int result = 0;
int calculatingShardingCount = shardingCount - 1;
- while (calculatingShardingCount != 0) {
+ while (0 != calculatingShardingCount) {
result++;
calculatingShardingCount = calculatingShardingCount / 10;
}
diff --git a/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-distsql/shardingsphere-authority-distsql-handler/src/main/java/org/apache/shardingsphere/authority/distsql/handler/AuthorityRuleQueryResultSet.java b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-distsql/shardingsphere-authority-distsql-handler/src/main/java/org/apache/shardingsphere/authority/distsql/handler/AuthorityRuleQueryResultSet.java
index 5a5f5c2569e..8309d79f020 100644
--- a/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-distsql/shardingsphere-authority-distsql-handler/src/main/java/org/apache/shardingsphere/authority/distsql/handler/AuthorityRuleQueryResultSet.java
+++ b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-distsql/shardingsphere-authority-distsql-handler/src/main/java/org/apache/shardingsphere/authority/distsql/handler/AuthorityRuleQueryResultSet.java
@@ -54,7 +54,7 @@ public final class AuthorityRuleQueryResultSet implements GlobalRuleDistSQLResul
private Collection<Collection<Object>> buildData(final AuthorityRuleConfiguration ruleConfig) {
Collection<Collection<Object>> result = new LinkedList<>();
result.add(Arrays.asList(ruleConfig.getUsers().stream().map(each -> each.getGrantee().toString()).collect(Collectors.joining("; ")),
- ruleConfig.getProvider().getType(), ruleConfig.getProvider().getProps().size() == 0 ? "" : ruleConfig.getProvider().getProps()));
+ ruleConfig.getProvider().getType(), ruleConfig.getProvider().getProps().isEmpty() ? "" : ruleConfig.getProvider().getProps()));
return result;
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/algorithm/AbstractStreamingDataConsistencyCalculateAlgorithm.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/algorithm/AbstractStreamingDataConsistencyCalculateAlgorithm.java
index d866a90a456..e35afffba1c 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/algorithm/AbstractStreamingDataConsistencyCalculateAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/algorithm/AbstractStreamingDataConsistencyCalculateAlgorithm.java
@@ -94,7 +94,7 @@ public abstract class AbstractStreamingDataConsistencyCalculateAlgorithm impleme
if (!nextResult.isPresent()) {
log.info("nextResult not present, calculation done. calculationCount={}", calculationCount);
}
- if (calculationCount.incrementAndGet() % 100_0000 == 0) {
+ if (0 == calculationCount.incrementAndGet() % 100_0000) {
log.warn("possible infinite loop, calculationCount={}", calculationCount);
}
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/channel/memory/ManualBitSet.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/channel/memory/ManualBitSet.java
index 1f09c6a5f5d..48165130515 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/channel/memory/ManualBitSet.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/channel/memory/ManualBitSet.java
@@ -87,7 +87,7 @@ public final class ManualBitSet {
* @return index
*/
public synchronized long getEndIndex(final long fromIndex, final int size) {
- if (size == 0) {
+ if (0 == size) {
return fromIndex;
}
int correctIndex = fromIndex < startIndex ? 0 : (int) (fromIndex - startIndex);
@@ -96,7 +96,7 @@ public final class ManualBitSet {
for (int i = listIndex; i < bitSets.size(); i++) {
int begin = i == listIndex ? correctIndex % BIT_SET_SIZE : 0;
for (int j = begin; j < BIT_SET_SIZE; j++) {
- if (bitSets.get(i).get(j) && --count == 0) {
+ if (bitSets.get(i).get(j) && 0 == --count) {
return startIndex + (long) i * BIT_SET_SIZE + j + 1;
}
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/prepare/InventoryTaskSplitter.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/prepare/InventoryTaskSplitter.java
index e8e6c315534..bee0a14f983 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/prepare/InventoryTaskSplitter.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/prepare/InventoryTaskSplitter.java
@@ -218,7 +218,7 @@ public final class InventoryTaskSplitter {
break;
}
long endId = rs.getLong(1);
- if (endId == 0) {
+ if (0 == endId) {
log.info("getPositionByPrimaryKeyRange, endId is 0, break, tableName={}, primaryKey={}, beginId={}", dumperConfig.getActualTableName(), dumperConfig.getUniqueKey(), beginId);
break;
}
@@ -227,7 +227,7 @@ public final class InventoryTaskSplitter {
}
}
// fix empty table missing inventory task
- if (0 == result.size()) {
+ if (result.isEmpty()) {
result.add(new IntegerPrimaryKeyPosition(0, 0));
}
} catch (final SQLException ex) {
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 ac081fe570c..9f26639ca49 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
@@ -70,7 +70,7 @@ public final class MppdbDecodingPlugin implements DecodingPlugin {
StringBuilder mppData = new StringBuilder();
mppData.append('{');
int depth = 1;
- while (depth != 0 && data.hasRemaining()) {
+ while (0 != depth && data.hasRemaining()) {
char next = (char) data.get();
mppData.append(next);
int optDepth = '{' == next ? 1 : ('}' == next ? -1 : 0);
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/ddlgenerator/PostgresConstraintsPropertiesAppender.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/PostgresConstraintsProp [...]
index 4cb35e44522..e54d8a9f819 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/PostgresConstraintsPropertiesAppender.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/PostgresConstraintsPropertiesAppender.java
@@ -147,8 +147,8 @@ public final class PostgresConstraintsPropertiesAppender extends AbstractPostgre
parameters.put("col_count", exclusionConstraintsProps.get("col_count"));
Collection<Map<String, Object>> columns = new LinkedList<>();
for (Map<String, Object> each : executeByTemplate(parameters, "component/exclusion_constraint/%s/get_constraint_cols.ftl")) {
- boolean order = (((int) each.get("options")) & 1) == 0;
- boolean nullsOrder = (((int) each.get("options")) & 2) != 0;
+ boolean order = 0 == (((int) each.get("options")) & 1);
+ boolean nullsOrder = 0 != (((int) each.get("options")) & 2);
Map<String, Object> col = new HashMap<>();
col.put("column", strip((String) each.get("coldef")));
col.put("oper_class", each.get("opcname"));
@@ -247,9 +247,9 @@ public final class PostgresConstraintsPropertiesAppender extends AbstractPostgre
Set<String> copyIndexCols = new HashSet<>(indexCols);
Set<String> copyCols = new HashSet<>(cols);
copyIndexCols.removeAll(copyCols);
- if (0 == copyIndexCols.size()) {
+ if (copyIndexCols.isEmpty()) {
cols.removeAll(indexCols);
- return 0 == cols.size();
+ return cols.isEmpty();
}
return false;
}
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepository.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/ [...]
index 0d01991a121..58164244b4d 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepository.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepository.java
@@ -121,7 +121,7 @@ public final class JDBCRepository implements StandalonePersistRepository {
String tempKey = tempPrefix + SEPARATOR + paths[i];
String tempKeyVal = get(tempKey);
if (Strings.isNullOrEmpty(tempKeyVal)) {
- if (i != 0) {
+ if (0 != i) {
parent = tempPrefix;
}
insert(tempKey, "", parent);
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/impl/MySQLFormatSQLVisitor.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/impl/MySQLFormatSQLVisitor.java
index 9d4cae8ec13..4ca7b526cbd 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/impl/MySQLFormatSQLVisitor.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/impl/MySQLFormatSQLVisitor.java
@@ -272,7 +272,7 @@ public abstract class MySQLFormatSQLVisitor extends MySQLStatementBaseVisitor<St
formatPrintln(" (");
int identifierCount = ctx.identifier().size();
for (int i = 0; i < identifierCount; i++) {
- if (i == 0) {
+ if (0 == i) {
visit(ctx.identifier(i));
} else {
formatPrint(" ,");
@@ -303,7 +303,7 @@ public abstract class MySQLFormatSQLVisitor extends MySQLStatementBaseVisitor<St
if (!ctx.assignmentValues().isEmpty()) {
int valueCount = ctx.assignmentValues().size();
for (int i = 0; i < valueCount; i++) {
- if (i == 0) {
+ if (0 == i) {
visit(ctx.assignmentValues(i));
} else {
formatPrint(",");
@@ -354,7 +354,7 @@ public abstract class MySQLFormatSQLVisitor extends MySQLStatementBaseVisitor<St
formatPrint(" ");
int assignmentCount = ctx.assignment().size();
for (int i = 0; i < assignmentCount; i++) {
- if (i == 0) {
+ if (0 == i) {
visit(ctx.assignment(i));
} else {
formatPrintln(",");
@@ -370,7 +370,7 @@ public abstract class MySQLFormatSQLVisitor extends MySQLStatementBaseVisitor<St
formatPrint("(");
int aliasCount = ctx.alias().size();
for (int i = 0; i < aliasCount; i++) {
- if (i == 0) {
+ if (0 == i) {
visit(ctx.alias(i));
} else {
formatPrint(", ");
@@ -394,7 +394,7 @@ public abstract class MySQLFormatSQLVisitor extends MySQLStatementBaseVisitor<St
indentCount++;
int assignmentCount = ctx.assignment().size();
for (int i = 0; i < assignmentCount; i++) {
- if (i == 0) {
+ if (0 == i) {
visit(ctx.assignment(i));
} else {
formatPrintln();
@@ -515,7 +515,7 @@ public abstract class MySQLFormatSQLVisitor extends MySQLStatementBaseVisitor<St
public String visitRowConstructorList(final RowConstructorListContext ctx) {
int rowCount = ctx.assignmentValues().size();
for (int i = 0; i < rowCount; i++) {
- if (i == 0) {
+ if (0 == i) {
visit(ctx.ROW(i));
formatPrint(" ");
visit(ctx.assignmentValues(i));
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/util/CommandPartUtil.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/util/CommandPartUtil.java
deleted file mode 100644
index b479e07e780..00000000000
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/util/CommandPartUtil.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.test.integration.env.container.atomic.util;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * Command part util.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class CommandPartUtil {
-
- /**
- * Merge command parts.
- *
- * @param defaultCommandParts default command parts
- * @param inputCommandParts input command parts, will override default command parts
- * @return merged command parts
- */
- public static String[] mergeCommandParts(final String[] defaultCommandParts, final String[] inputCommandParts) {
- if (null == defaultCommandParts || defaultCommandParts.length == 0) {
- return inputCommandParts;
- }
- if (null == inputCommandParts || inputCommandParts.length == 0) {
- return defaultCommandParts;
- }
- Map<String, String> defaultPartsMap = new LinkedHashMap<>();
- for (String each : defaultCommandParts) {
- String[] split = each.split("=");
- defaultPartsMap.put(split[0], split[1]);
- }
- for (String each : inputCommandParts) {
- String[] split = each.split("=");
- defaultPartsMap.put(split[0], split[1]);
- }
- return defaultPartsMap.entrySet().stream().map(entry -> entry.getKey() + "=" + entry.getValue()).toArray(String[]::new);
- }
-}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/task/MySQLIncrementTask.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/task/MySQLIncrementTask.java
index 4c6e466aaf6..706945a4df3 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/task/MySQLIncrementTask.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/task/MySQLIncrementTask.java
@@ -28,8 +28,8 @@ import org.springframework.jdbc.core.JdbcTemplate;
import java.time.Instant;
import java.util.concurrent.ThreadLocalRandom;
-@Slf4j
@RequiredArgsConstructor
+@Slf4j
public final class MySQLIncrementTask extends BaseIncrementTask {
private final JdbcTemplate jdbcTemplate;
@@ -43,7 +43,7 @@ public final class MySQLIncrementTask extends BaseIncrementTask {
int executeCount = 0;
while (executeCount < executeCountLimit && !Thread.currentThread().isInterrupted()) {
Object orderPrimaryKey = insertOrder();
- if (executeCount % 2 == 0) {
+ if (0 == executeCount % 2) {
jdbcTemplate.update("DELETE FROM t_order_copy WHERE order_id = ?", orderPrimaryKey);
} else {
setNullToOrderFields(orderPrimaryKey);
@@ -66,7 +66,7 @@ public final class MySQLIncrementTask extends BaseIncrementTask {
private Object insertOrderItem() {
ThreadLocalRandom random = ThreadLocalRandom.current();
- String status = random.nextInt() % 2 == 0 ? null : "NOT-NULL";
+ String status = 0 == random.nextInt() % 2 ? null : "NOT-NULL";
Object[] orderInsertItemDate = new Object[]{primaryKeyGenerateAlgorithm.generateKey(), ScalingCaseHelper.generateSnowflakeKey(), random.nextInt(0, 6), status};
jdbcTemplate.update("INSERT INTO t_order_item(item_id,order_id,user_id,status) VALUES(?, ?, ?, ?)", orderInsertItemDate);
return orderInsertItemDate[0];
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/task/PostgreSQLIncrementTask.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/task/PostgreSQLIncrementTask.java
index e4e4c24a9fc..2836e84ff6e 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/task/PostgreSQLIncrementTask.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/task/PostgreSQLIncrementTask.java
@@ -55,7 +55,7 @@ public final class PostgreSQLIncrementTask extends BaseIncrementTask {
int executeCount = 0;
while (executeCount < executeCountLimit && !Thread.currentThread().isInterrupted()) {
Object orderId = insertOrder();
- if (executeCount % 2 == 0) {
+ if (0 == executeCount % 2) {
jdbcTemplate.update(prefixSchema("DELETE FROM ${schema}t_order_copy WHERE order_id = ?", schema), orderId);
} else {
updateOrderByPrimaryKey(orderId);
@@ -72,7 +72,7 @@ public final class PostgreSQLIncrementTask extends BaseIncrementTask {
private Object insertOrder() {
ThreadLocalRandom random = ThreadLocalRandom.current();
- String status = random.nextInt() % 2 == 0 ? null : "NOT-NULL";
+ String status = 0 == random.nextInt() % 2 ? null : "NOT-NULL";
Object[] orderInsertDate = new Object[]{KEY_GENERATE_ALGORITHM.generateKey(), random.nextInt(0, 6), status};
jdbcTemplate.update(prefixSchema("INSERT INTO ${schema}t_order_copy (order_id,user_id,status) VALUES (?, ?, ?)", schema), orderInsertDate);
return orderInsertDate[0];
@@ -80,7 +80,7 @@ public final class PostgreSQLIncrementTask extends BaseIncrementTask {
private Object insertOrderItem() {
ThreadLocalRandom random = ThreadLocalRandom.current();
- String status = random.nextInt() % 2 == 0 ? null : "NOT-NULL";
+ String status = 0 == random.nextInt() % 2 ? null : "NOT-NULL";
Object[] orderInsertItemDate = new Object[]{KEY_GENERATE_ALGORITHM.generateKey(), ScalingCaseHelper.generateSnowflakeKey(), random.nextInt(0, 6), status};
jdbcTemplate.update(prefixSchema("INSERT INTO ${schema}t_order_item(item_id,order_id,user_id,status) VALUES(?,?,?,?)", schema), orderInsertItemDate);
return orderInsertItemDate[0];