From 8e6a331faa5c759221843b33d5dc89133bf4c8a1 Mon Sep 17 00:00:00 2001 From: Symious Date: Mon, 25 Nov 2024 09:56:17 +0800 Subject: [PATCH] RATIS-2199. Release once on exception --- .../org/apache/ratis/netty/server/DataStreamManagement.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ratis-netty/src/main/java/org/apache/ratis/netty/server/DataStreamManagement.java b/ratis-netty/src/main/java/org/apache/ratis/netty/server/DataStreamManagement.java index 74d5cd7fde..64cd16d097 100644 --- a/ratis-netty/src/main/java/org/apache/ratis/netty/server/DataStreamManagement.java +++ b/ratis-netty/src/main/java/org/apache/ratis/netty/server/DataStreamManagement.java @@ -476,13 +476,17 @@ private void readImpl(DataStreamRequestByteBuf request, ChannelHandlerContext ct } return null; }, requestExecutor)).whenComplete((v, exception) -> { + boolean released = false; try { if (exception != null) { replyDataStreamException(server, exception, info.getRequest(), request, ctx); removeDataStream(key, info); + released = true; } } finally { - request.release(); + if (!released) { + request.release(); + } channels.remove(channelId, key); } });