AlbumenJ commented on code in PR #14538:
URL: https://github.com/apache/dubbo/pull/14538#discussion_r1724179606
##########
dubbo-remoting/dubbo-remoting-netty4/src/test/java/org/apache/dubbo/remoting/transport/netty4/NettyCodecAdapterTest.java:
##########
@@ -42,4 +55,30 @@ void test() {
Assertions.assertTrue(decoder instanceof ByteToMessageDecoder);
Assertions.assertTrue(encoder instanceof MessageToByteEncoder);
}
+
+ @Test
+ void testDecodeException() throws IOException {
+ Codec2 codec2 = Mockito.mock(Codec2.class);
+ doThrow(new
IOException("testDecodeIllegalPacket")).when(codec2).decode(any(), any());
+
+ URL url = Mockito.mock(URL.class);
+ doReturn("default").when(url).getParameter(eq(Constants.CODEC_KEY));
+
+ ChannelHandler handler = Mockito.mock(ChannelHandler.class);
+ NettyCodecAdapter nettyCodecAdapter = new NettyCodecAdapter(codec2,
url, handler);
+ io.netty.channel.ChannelHandler decoder =
nettyCodecAdapter.getDecoder();
+ EmbeddedChannel embeddedChannel = new EmbeddedChannel();
+ embeddedChannel.pipeline().addLast(decoder);
+
+ // 模拟问题数据包
Review Comment:
Comment in English
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]