Shilun Fan created RATIS-2416:
---------------------------------
Summary: Fix memory leak in NettyClientReplies for stale replies
Key: RATIS-2416
URL: https://issues.apache.org/jira/browse/RATIS-2416
Project: Ratis
Issue Type: Bug
Components: Netty
Reporter: Shilun Fan
Assignee: Shilun Fan
*Problem:*
When {{NettyClientStreamRpc.channelRead()}} receives an unknown/invalid reply
(a reply without a corresponding request), it creates an empty in the
ConcurrentHashMap that is never removed, causing a memory leak over time.
*Root Cause:*
- {{channelRead()}} calls for every received reply
{{replies.getReplyMap(clientInvocationId)}}
- {{getReplyMap()}} uses {{computeIfAbsent}} which creates a new empty map if
the invocation ID doesn't exist
- When the reply is unknown, {{receiveReply()}} finds {{replyEntry == null}}
and returns early
- The empty map remains in memory permanently
--
This message was sent by Atlassian Jira
(v8.20.10#820010)