From f4bb0c553536e0bb4faf45dc087799cd48b5827a Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Wed, 23 Jul 2025 19:19:54 -1000 Subject: [PATCH] Release buffer when serialization throws exception Motivation: We need to release the previous allocated buffer if serialization throws an exception as otherwise we will leak it. Modifications: Correctly release buffer if serialization throws an exception Result: No more buffer leak when serialization fails --- .../io/netty/incubator/codec/ohttp/OHttpServerCodec.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/codec-ohttp/src/main/java/io/netty/incubator/codec/ohttp/OHttpServerCodec.java b/codec-ohttp/src/main/java/io/netty/incubator/codec/ohttp/OHttpServerCodec.java index be58efa..ed0693f 100644 --- a/codec-ohttp/src/main/java/io/netty/incubator/codec/ohttp/OHttpServerCodec.java +++ b/codec-ohttp/src/main/java/io/netty/incubator/codec/ohttp/OHttpServerCodec.java @@ -24,8 +24,6 @@ import io.netty.buffer.Unpooled; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.DecoderException; -import io.netty.handler.codec.EncoderException; import io.netty.handler.codec.http.DefaultFullHttpResponse; import io.netty.handler.codec.http.DefaultHttpContent; import io.netty.handler.codec.http.DefaultHttpRequest; @@ -235,14 +233,18 @@ protected final void encode(ChannelHandlerContext ctx, HttpObject msg, List