Skip to content

Commit

Permalink
Added bytebuf release to http request decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Dunne committed Aug 19, 2014
1 parent bf59280 commit 6b77d75
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import io.netty.handler.codec.MessageToMessageDecoder;
import io.netty.handler.codec.http.HttpContent;
import io.netty.handler.codec.http.HttpHeaders;
import io.netty.util.ReferenceCountUtil;

import org.jboss.resteasy.core.SynchronousDispatcher;
import org.jboss.resteasy.logging.Logger;
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
Expand Down Expand Up @@ -70,9 +72,15 @@ protected void decode(ChannelHandlerContext ctx, io.netty.handler.codec.http.Htt
{
HttpContent content = (HttpContent) request;
ByteBuf buf = content.content().retain();
ByteBufInputStream in = new ByteBufInputStream(buf);
nettyRequest.setInputStream(in);
out.add(nettyRequest);
try {
ByteBufInputStream in = new ByteBufInputStream(buf);
nettyRequest.setInputStream(in);
out.add(nettyRequest);
}
finally
{
ReferenceCountUtil.release(buf);
}
}
}
catch (Exception e)
Expand Down

3 comments on commit 6b77d75

@avram
Copy link
Contributor

@avram avram commented on 6b77d75 Oct 16, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was this trying to address? This is is the only marginally likely culprit I can identify for https://issues.jboss.org/browse/RESTEASY-1116 -- but I don't what motivated this change

@hypnopadge
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was added to fix a resource leak reported by netty when performing GET requests as the ByteBuf was not being released. But it does seem that this change has affected POST requests specifically those that have a body passed to the jaxrs endpoint.

@superyizhi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with the latest 3.0.11.final the netty resource leak still reported. how to prevent that?

Please sign in to comment.