YongGoose commented on code in PR #7505: URL: https://github.com/apache/incubator-seata/pull/7505#discussion_r2196352884
########## core/src/test/java/org/apache/seata/core/rpc/netty/ResourceCleanupTest.java: ########## @@ -143,6 +145,26 @@ void testCleanupWithNullChannel() { assertTrue(futures.containsKey(1), "Future ID 1 should still exist"); } + @Test + void testExceptionCaughtTriggersChannelRelease() throws Exception { + AbstractNettyRemotingClient.ClientHandler handler = client.new ClientHandler(); + ChannelHandlerContext mockCtx = mock(ChannelHandlerContext.class); + when(mockCtx.channel()).thenReturn(channel); + when(channel.remoteAddress()).thenReturn(new InetSocketAddress("127.0.0.1", 8091)); + Field channelManagerField = AbstractNettyRemotingClient.class.getDeclaredField("clientChannelManager"); + channelManagerField.setAccessible(true); + NettyClientChannelManager originalManager = (NettyClientChannelManager) channelManagerField.get(client); + + NettyClientChannelManager spyManager = spy(originalManager); + channelManagerField.set(client, spyManager); + + handler.exceptionCaught(mockCtx, new IllegalArgumentException("test")); + + Thread.sleep(500); + verify(spyManager).releaseChannel(eq(channel), anyString()); Review Comment: Is there a specific reason you used `anyString()`? It seems like serverAddress will always be `127.0.0.1:8091`, so I’m wondering if matching the exact value would be more appropriate. -- 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: notifications-unsubscr...@seata.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org For additional commands, e-mail: notifications-h...@seata.apache.org