diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/codec/MySQLPacketCodecEngine.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/codec/MySQLPacketCodecEngine.java index ac7bf823421f899c7a25f69dc5150a9ce44eb6f1..c119c96428154b0076e1100d18563a1d9ea3bba0 100644 --- a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/codec/MySQLPacketCodecEngine.java +++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/codec/MySQLPacketCodecEngine.java @@ -32,7 +32,7 @@ public final class MySQLPacketCodecEngine implements DatabasePacketCodecEngine MySQLPacket.PAYLOAD_LENGTH + MySQLPacket.SEQUENCE_LENGTH; + return readableBytes >= MySQLPacket.PAYLOAD_LENGTH + MySQLPacket.SEQUENCE_LENGTH; } @Override diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/codec/MySQLPacketCodecEngineTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/codec/MySQLPacketCodecEngineTest.java index ecfb2bbe730de95ddc30cb45eae39f25d089f5cc..19c33ea0d0d11511a95158ba12471cdca33b769e 100644 --- a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/codec/MySQLPacketCodecEngineTest.java +++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/codec/MySQLPacketCodecEngineTest.java @@ -66,7 +66,16 @@ public final class MySQLPacketCodecEngineTest { new MySQLPacketCodecEngine().decode(context, byteBuf, out, 54); assertThat(out.size(), is(1)); } - + + @Test + public void assertDecodeWithEmptyPacket() { + when(byteBuf.markReaderIndex()).thenReturn(byteBuf); + when(byteBuf.readMediumLE()).thenReturn(0); + List out = new LinkedList<>(); + new MySQLPacketCodecEngine().decode(context, byteBuf, out, 4); + assertThat(out.size(), is(1)); + } + @Test public void assertDecodeWithStickyPacket() { when(byteBuf.markReaderIndex()).thenReturn(byteBuf); diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/auth/MySQLAuthenticationHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/auth/MySQLAuthenticationHandlerTest.java index 7adb6c73c74728975724821c263ad8e8adf48eb6..70afb3e4cdeb7017537ee47dca0da539ee09b988 100644 --- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/auth/MySQLAuthenticationHandlerTest.java +++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/auth/MySQLAuthenticationHandlerTest.java @@ -90,7 +90,7 @@ public final class MySQLAuthenticationHandlerTest { @Test public void assertLoginWithoutPassword() { setAuthentication(new ProxyUser(null, null)); - byte[] authResponse = {-27, 89, -20, -27, 65, -120, -64, -101, 86, -100, -108, -100, 6, -125, -37, 117, 14, -43, 95, -113}; + byte[] authResponse = {}; assertFalse(authenticationHandler.login("root", authResponse, "db1").isPresent()); }