You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2026/09/20 15:59:44 UTC

(shardingsphere) branch master updated: Refactor FirebirdConnectionResourceManagerTest (#39907)

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

terrymanu 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 5de066090b9 Refactor FirebirdConnectionResourceManagerTest (#39907)
5de066090b9 is described below

commit 5de066090b9859a5d30021b5447fb4a3adc166dc
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sun Sep 20 23:59:37 2026 +0800

    Refactor FirebirdConnectionResourceManagerTest (#39907)
---
 .../command/query/batch/FirebirdBatchStatementManager.java  | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/batch/FirebirdBatchStatementManager.java b/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/batch/FirebirdBatchStatementManager.java
index 961bda92a87..2a54f97801f 100644
--- a/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/batch/FirebirdBatchStatementManager.java
+++ b/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/batch/FirebirdBatchStatementManager.java
@@ -25,6 +25,7 @@ import org.apache.shardingsphere.database.protocol.firebird.packet.command.query
 import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.batch.FirebirdBatchMessageCommandPacket;
 import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.batch.FirebirdBatchRegistry;
 import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.batch.FirebirdBatchStatement;
+import org.apache.shardingsphere.infra.exception.ShardingSpherePreconditions;
 
 import java.util.List;
 
@@ -100,16 +101,14 @@ public final class FirebirdBatchStatementManager {
      */
     public void appendBatchMessage(final int connectionId, final FirebirdBatchMessageCommandPacket packet) {
         FirebirdBatchStatement batchStatement = getBatchStatement(connectionId, packet.getStatementHandle());
-        if (null == batchStatement) {
-            throw new InvalidBatchHandleException(packet.getStatementHandle());
-        }
-        if (batchStatement.getAccumulatedSize() + packet.getDataLength() > batchStatement.getBufferSize()) {
-            throw new BatchTooBigException(packet.getStatementHandle(), batchStatement.getAccumulatedSize(), packet.getDataLength(), batchStatement.getBufferSize());
-        }
+        ShardingSpherePreconditions.checkNotNull(batchStatement, () -> new InvalidBatchHandleException(packet.getStatementHandle()));
+        int dataLength = packet.getDataLength();
+        ShardingSpherePreconditions.checkState(batchStatement.getAccumulatedSize() + dataLength <= batchStatement.getBufferSize(),
+                () -> new BatchTooBigException(packet.getStatementHandle(), batchStatement.getAccumulatedSize(), dataLength, batchStatement.getBufferSize()));
         for (List<Object> each : packet.readParameterValues(batchStatement.getColumnDescriptors())) {
             batchStatement.addParameterValues(each);
         }
-        batchStatement.addSize(packet.getDataLength());
+        batchStatement.addSize(dataLength);
     }
     
     /**