未验证 提交 83942fd2 编写于 作者: T tony.li 提交者: GitHub

Add a case with empty data packet (#7017) (#7048)

上级 a8fbbc21
......@@ -32,7 +32,7 @@ public final class MySQLPacketCodecEngine implements DatabasePacketCodecEngine<M
@Override
public boolean isValidHeader(final int readableBytes) {
return readableBytes > MySQLPacket.PAYLOAD_LENGTH + MySQLPacket.SEQUENCE_LENGTH;
return readableBytes >= MySQLPacket.PAYLOAD_LENGTH + MySQLPacket.SEQUENCE_LENGTH;
}
@Override
......
......@@ -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<Object> out = new LinkedList<>();
new MySQLPacketCodecEngine().decode(context, byteBuf, out, 4);
assertThat(out.size(), is(1));
}
@Test
public void assertDecodeWithStickyPacket() {
when(byteBuf.markReaderIndex()).thenReturn(byteBuf);
......
......@@ -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());
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册