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 896df7b0ecd Fix NPE when getting estimated count result set is empty
(#34295)
896df7b0ecd is described below
commit 896df7b0ecd5e132e846d14ec0f0f9bc7588d214
Author: ZhangCheng <[email protected]>
AuthorDate: Fri Jan 10 12:34:59 2025 +0800
Fix NPE when getting estimated count result set is empty (#34295)
---
.../preparer/inventory/calculator/InventoryRecordsCountCalculator.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/inventory/calculator/InventoryRecordsCountCalculator.java
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/inventory/calculator/InventoryRecordsCountCalculator.java
index fa9276228ec..008b06421c3 100644
---
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/inventory/calculator/InventoryRecordsCountCalculator.java
+++
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/inventory/calculator/InventoryRecordsCountCalculator.java
@@ -80,8 +80,7 @@ public final class InventoryRecordsCountCalculator {
Connection connection = dataSource.getConnection();
PreparedStatement preparedStatement =
connection.prepareStatement(estimatedCountSQL)) {
try (ResultSet resultSet = preparedStatement.executeQuery()) {
- resultSet.next();
- return resultSet.getLong(1);
+ return resultSet.next() ? resultSet.getLong(1) : 0;
}
}
}