This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 9b7b14e3217 Fix code inspections for db-protocol modules (#31390)
9b7b14e3217 is described below
commit 9b7b14e32176339c867c9174ffc6c4a9584fe899
Author: Liang Zhang <[email protected]>
AuthorDate: Sat May 25 20:02:43 2024 +0800
Fix code inspections for db-protocol modules (#31390)
* Remove DataSourceUnitPersistService.deleteConfigurations
* Add override on JDBCBackendDataSource
* Remove useless codes
* Remove useless codes
* Fix code inspections for db-protocol modules
---
.../row/column/value/decimal/MySQLDecimalBinlogProtocolValue.java | 7 +++++--
.../binlog/row/column/value/string/MySQLJsonValueDecoder.java | 4 +++-
.../mysql/packet/handshake/MySQLAuthSwitchRequestPacket.java | 3 +--
.../binlog/row/column/value/string/MySQLJsonValueDecoderTest.java | 3 ++-
.../packet/command/admin/PostgreSQLUnsupportedCommandPacket.java | 2 +-
5 files changed, 12 insertions(+), 7 deletions(-)
diff --git
a/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/decimal/MySQLDecimalBinlogProtocolValue.java
b/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/decimal/MySQLDecimalBinlogProtocolValue.java
index 55055dd28f5..a785390c80f 100644
---
a/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/decimal/MySQLDecimalBinlogProtocolValue.java
+++
b/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/decimal/MySQLDecimalBinlogProtocolValue.java
@@ -61,9 +61,10 @@ public final class MySQLDecimalBinlogProtocolValue
implements MySQLBinlogProtoco
private static BigDecimal decodeIntegerValue(final DecimalMetaData
metaData, final byte[] value) {
int offset = DIG_TO_BYTES[metaData.getExtraIntegerSize()];
BigDecimal result = offset > 0 ?
BigDecimal.valueOf(readFixedLengthIntBE(value, 0, offset)) : BigDecimal.ZERO;
- for (; offset < metaData.getIntegerByteLength(); offset +=
DEC_BYTE_SIZE) {
+ while (offset < metaData.getIntegerByteLength()) {
int i = readFixedLengthIntBE(value, offset, DEC_BYTE_SIZE);
result =
result.movePointRight(DIG_PER_DEC).add(BigDecimal.valueOf(i));
+ offset += DEC_BYTE_SIZE;
}
return result;
}
@@ -73,8 +74,10 @@ public final class MySQLDecimalBinlogProtocolValue
implements MySQLBinlogProtoco
int shift = 0;
int offset = metaData.getIntegerByteLength();
int scale = metaData.getScale();
- for (; shift + DIG_PER_DEC <= scale; shift += DIG_PER_DEC, offset +=
DEC_BYTE_SIZE) {
+ while (shift + DIG_PER_DEC <= scale) {
result = result.add(BigDecimal.valueOf(readFixedLengthIntBE(value,
offset, DEC_BYTE_SIZE)).movePointLeft(shift + DIG_PER_DEC));
+ shift += DIG_PER_DEC;
+ offset += DEC_BYTE_SIZE;
}
if (shift < scale) {
result = result.add(BigDecimal.valueOf(readFixedLengthIntBE(value,
offset, DIG_TO_BYTES[scale - shift])).movePointLeft(scale));
diff --git
a/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonValueDecoder.java
b/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonValueDecoder.java
index 8da0ac33b98..e3f8d29f861 100644
---
a/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonValueDecoder.java
+++
b/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonValueDecoder.java
@@ -214,12 +214,14 @@ public final class MySQLJsonValueDecoder {
private static int decodeDataLength(final ByteBuf byteBuf) {
int result = 0;
- for (int i = 0;; i++) {
+ int i = 0;
+ while (true) {
int data = byteBuf.readUnsignedByte();
result |= (data & 0x7f) << (7 * i);
if (0 == (data & 0x80)) {
break;
}
+ i++;
}
return result;
}
diff --git
a/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/handshake/MySQLAuthSwitchRequestPacket.java
b/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/handshake/MySQLAuthSwitchRequestPacket.java
index d6d93ea3763..d7265f39ab8 100644
---
a/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/handshake/MySQLAuthSwitchRequestPacket.java
+++
b/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/handshake/MySQLAuthSwitchRequestPacket.java
@@ -31,6 +31,7 @@ import java.util.Arrays;
* @see <a
href="https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_connection_phase_packets_protocol_auth_switch_request.html">AuthSwitchRequest</a>
*/
@RequiredArgsConstructor
+@Getter
public final class MySQLAuthSwitchRequestPacket extends MySQLPacket {
/**
@@ -38,10 +39,8 @@ public final class MySQLAuthSwitchRequestPacket extends
MySQLPacket {
*/
public static final int HEADER = 0xfe;
- @Getter
private final String authPluginName;
- @Getter
private final MySQLAuthenticationPluginData authPluginData;
public MySQLAuthSwitchRequestPacket(final MySQLPacketPayload payload) {
diff --git
a/db-protocol/mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonValueDecoderTest.java
b/db-protocol/mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonValueDecoderTest.java
index 3c5f641c343..e8ce970d2a8 100644
---
a/db-protocol/mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonValueDecoderTest.java
+++
b/db-protocol/mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonValueDecoderTest.java
@@ -370,10 +370,11 @@ class MySQLJsonValueDecoderTest {
}
// compress
int index = lengthData.length - 1;
- for (; index > 0; index--) {
+ while (index > 0) {
if (0 != lengthData[index]) {
break;
}
+ index--;
}
for (int i = 0; i < index; i++) {
lengthData[i] |= 0x80;
diff --git
a/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/admin/PostgreSQLUnsupportedCommandPacket.java
b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/admin/PostgreSQLUnsupportedCommandPacket.java
index 976c968d957..1cdf47193d7 100644
---
a/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/admin/PostgreSQLUnsupportedCommandPacket.java
+++
b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/admin/PostgreSQLUnsupportedCommandPacket.java
@@ -27,9 +27,9 @@ import
org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacket
* Unsupported command packet for PostgreSQL.
*/
@RequiredArgsConstructor
+@Getter
public final class PostgreSQLUnsupportedCommandPacket extends
PostgreSQLCommandPacket {
- @Getter
private final PostgreSQLIdentifierTag identifier;
@Override