Dltmd202 commented on code in PR #7505:
URL: https://github.com/apache/incubator-seata/pull/7505#discussion_r2201130128
##########
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:
You’re right — that makes sense to me as well. I’ll go ahead and update it
to match the exact value instead of using `anyString()`.
--
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]