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

zhangliang 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 214da16c68c Remove unreached codes on FirebirdPacketCodecEngine 
(#38150)
214da16c68c is described below

commit 214da16c68cf08a214d2cbf15ba749012fc34e26
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Feb 23 01:01:46 2026 +0800

    Remove unreached codes on FirebirdPacketCodecEngine (#38150)
---
 .../protocol/firebird/codec/FirebirdPacketCodecEngine.java        | 5 +----
 .../protocol/firebird/codec/FirebirdPacketCodecEngineTest.java    | 8 ++++----
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git 
a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/codec/FirebirdPacketCodecEngine.java
 
b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/codec/FirebirdPacketCodecEngine.java
index 3ef7c118dc0..a5c934db5ab 100644
--- 
a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/codec/FirebirdPacketCodecEngine.java
+++ 
b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/codec/FirebirdPacketCodecEngine.java
@@ -54,7 +54,7 @@ public final class FirebirdPacketCodecEngine implements 
DatabasePacketCodecEngin
     
     @Override
     public void decode(final ChannelHandlerContext context, final ByteBuf in, 
final List<Object> out) {
-        if (pendingMessages.isEmpty() && isValidHeader(in.readableBytes())) {
+        if (pendingMessages.isEmpty()) {
             int type = in.getInt(in.readerIndex());
             pendingPacketType = FirebirdCommandPacketType.valueOf(type);
             if (pendingPacketType == 
FirebirdCommandPacketType.ALLOCATE_STATEMENT) {
@@ -76,9 +76,6 @@ public final class FirebirdPacketCodecEngine implements 
DatabasePacketCodecEngin
     }
     
     private void addToBuffer(final ChannelHandlerContext context, final 
ByteBuf in, final List<Object> out) {
-        if (!in.isReadable()) {
-            return;
-        }
         ByteBuf buffer = mergePendingMessages(context, in);
         boolean shouldRelease = buffer != in;
         try {
diff --git 
a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/codec/FirebirdPacketCodecEngineTest.java
 
b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/codec/FirebirdPacketCodecEngineTest.java
index 8931b0cf496..daa5afadbe9 100644
--- 
a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/codec/FirebirdPacketCodecEngineTest.java
+++ 
b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/codec/FirebirdPacketCodecEngineTest.java
@@ -88,7 +88,7 @@ class FirebirdPacketCodecEngineTest {
     void assertDecodeSingleAllocateStatement() {
         ByteBuf in = mock(ByteBuf.class);
         ByteBuf slice = mock(ByteBuf.class);
-        when(in.readableBytes()).thenReturn(8, 0);
+        when(in.readableBytes()).thenReturn(0);
         when(in.readerIndex()).thenReturn(0);
         
when(in.getInt(0)).thenReturn(FirebirdCommandPacketType.ALLOCATE_STATEMENT.getValue());
         when(in.readRetainedSlice(8)).thenReturn(slice);
@@ -104,7 +104,7 @@ class FirebirdPacketCodecEngineTest {
         ByteBuf in = mock(ByteBuf.class);
         ByteBuf slice1 = mock(ByteBuf.class);
         ByteBuf slice2 = mock(ByteBuf.class);
-        when(in.readableBytes()).thenReturn(16, 8, 8, 0);
+        when(in.readableBytes()).thenReturn(8, 0);
         when(in.readerIndex()).thenReturn(0);
         
when(in.getInt(0)).thenReturn(FirebirdCommandPacketType.ALLOCATE_STATEMENT.getValue());
         when(in.readRetainedSlice(8)).thenReturn(slice1, slice2);
@@ -123,7 +123,7 @@ class FirebirdPacketCodecEngineTest {
         
when(in.getInt(0)).thenReturn(FirebirdCommandPacketType.INFO_REQUEST.getValue());
         when(in.writerIndex()).thenReturn(8);
         when(in.capacity()).thenReturn(16);
-        when(in.isReadable()).thenReturn(true, true, false);
+        when(in.isReadable()).thenReturn(true, false);
         when(in.retainedSlice(anyInt(), anyInt())).thenReturn(payloadSlice);
         when(payloadSlice.release()).thenReturn(true);
         when(in.readRetainedSlice(8)).thenReturn(slice);
@@ -191,7 +191,7 @@ class FirebirdPacketCodecEngineTest {
         
when(in.getInt(0)).thenReturn(FirebirdCommandPacketType.PREPARE_STATEMENT.getValue());
         when(in.writerIndex()).thenReturn(8);
         when(in.capacity()).thenReturn(8);
-        when(in.isReadable()).thenReturn(true, true, false);
+        when(in.isReadable()).thenReturn(true, false);
         when(in.retainedSlice(anyInt(), anyInt())).thenReturn(payloadSlice);
         when(payloadSlice.release()).thenReturn(true);
         when(in.readRetainedSlice(8)).thenReturn(slice);

Reply via email to