This is an automated email from the ASF dual-hosted git repository.
zhonghongsheng 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 9329b7517b8 Fix sonar issue in pipeline: PRNG and null check (#25963)
9329b7517b8 is described below
commit 9329b7517b8e289b2298ccac40fafc031e9c1bc5
Author: Xinze Guo <[email protected]>
AuthorDate: Thu Jun 1 11:41:06 2023 +0800
Fix sonar issue in pipeline: PRNG and null check (#25963)
---
.../data/pipeline/mysql/ingest/MySQLIncrementalDumper.java | 3 +--
.../shardingsphere/data/pipeline/mysql/ingest/client/MySQLClient.java | 4 +++-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git
a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLIncrementalDumper.java
b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLIncrementalDumper.java
index 4e3fc6bc0b5..1c7c90a39c2 100644
---
a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLIncrementalDumper.java
+++
b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLIncrementalDumper.java
@@ -59,7 +59,6 @@ import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
-import java.util.concurrent.ThreadLocalRandom;
/**
* MySQL incremental dumper.
@@ -89,7 +88,7 @@ public final class MySQLIncrementalDumper extends
AbstractLifecycleExecutor impl
YamlJdbcConfiguration jdbcConfig =
((StandardPipelineDataSourceConfiguration)
dumperConfig.getDataSourceConfig()).getJdbcConfig();
log.info("incremental dump, jdbcUrl={}", jdbcConfig.getUrl());
DataSourceMetaData metaData =
TypedSPILoader.getService(DatabaseType.class,
"MySQL").getDataSourceMetaData(jdbcConfig.getUrl(), null);
- ConnectInfo connectInfo = new
ConnectInfo(ThreadLocalRandom.current().nextInt(), metaData.getHostname(),
metaData.getPort(), jdbcConfig.getUsername(), jdbcConfig.getPassword());
+ ConnectInfo connectInfo = new ConnectInfo(Math.abs(hashCode()),
metaData.getHostname(), metaData.getPort(), jdbcConfig.getUsername(),
jdbcConfig.getPassword());
client = new MySQLClient(connectInfo, dumperConfig.isDecodeWithTX());
catalog = metaData.getCatalog();
}
diff --git
a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClient.java
b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClient.java
index 5eac27cd25e..6d579b5084e 100644
---
a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClient.java
+++
b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClient.java
@@ -157,7 +157,9 @@ public final class MySQLClient {
MySQLComQueryPacket comQueryPacket = new
MySQLComQueryPacket(queryString, false);
resetSequenceID();
channel.writeAndFlush(comQueryPacket);
- return waitExpectedResponse(InternalResultSet.class);
+ InternalResultSet result =
waitExpectedResponse(InternalResultSet.class);
+ ShardingSpherePreconditions.checkNotNull(result, () -> new
PipelineInternalException("Unexpected null value of response"));
+ return result;
}
/**