* We should release the buffers right after copying and not only do so after we did all the request handling on the copy * Relates #44564
This commit is contained in:
parent
f575370e2f
commit
4495140d1f
|
@ -41,9 +41,9 @@ class Netty4HttpRequestHandler extends SimpleChannelInboundHandler<HttpPipelined
|
|||
protected void channelRead0(ChannelHandlerContext ctx, HttpPipelinedRequest<FullHttpRequest> msg) {
|
||||
Netty4HttpChannel channel = ctx.channel().attr(Netty4HttpServerTransport.HTTP_CHANNEL_KEY).get();
|
||||
FullHttpRequest request = msg.getRequest();
|
||||
|
||||
final FullHttpRequest copiedRequest;
|
||||
try {
|
||||
final FullHttpRequest copiedRequest =
|
||||
copiedRequest =
|
||||
new DefaultFullHttpRequest(
|
||||
request.protocolVersion(),
|
||||
request.method(),
|
||||
|
@ -51,24 +51,23 @@ class Netty4HttpRequestHandler extends SimpleChannelInboundHandler<HttpPipelined
|
|||
Unpooled.copiedBuffer(request.content()),
|
||||
request.headers(),
|
||||
request.trailingHeaders());
|
||||
|
||||
Netty4HttpRequest httpRequest = new Netty4HttpRequest(copiedRequest, msg.getSequence());
|
||||
|
||||
if (request.decoderResult().isFailure()) {
|
||||
Throwable cause = request.decoderResult().cause();
|
||||
if (cause instanceof Error) {
|
||||
ExceptionsHelper.maybeDieOnAnotherThread(cause);
|
||||
serverTransport.incomingRequestError(httpRequest, channel, new Exception(cause));
|
||||
} else {
|
||||
serverTransport.incomingRequestError(httpRequest, channel, (Exception) cause);
|
||||
}
|
||||
} else {
|
||||
serverTransport.incomingRequest(httpRequest, channel);
|
||||
}
|
||||
} finally {
|
||||
// As we have copied the buffer, we can release the request
|
||||
request.release();
|
||||
}
|
||||
Netty4HttpRequest httpRequest = new Netty4HttpRequest(copiedRequest, msg.getSequence());
|
||||
|
||||
if (request.decoderResult().isFailure()) {
|
||||
Throwable cause = request.decoderResult().cause();
|
||||
if (cause instanceof Error) {
|
||||
ExceptionsHelper.maybeDieOnAnotherThread(cause);
|
||||
serverTransport.incomingRequestError(httpRequest, channel, new Exception(cause));
|
||||
} else {
|
||||
serverTransport.incomingRequestError(httpRequest, channel, (Exception) cause);
|
||||
}
|
||||
} else {
|
||||
serverTransport.incomingRequest(httpRequest, channel);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -159,33 +159,32 @@ public class HttpReadWriteHandler implements NioChannelHandler {
|
|||
final HttpPipelinedRequest<FullHttpRequest> pipelinedRequest = (HttpPipelinedRequest<FullHttpRequest>) msg;
|
||||
FullHttpRequest request = pipelinedRequest.getRequest();
|
||||
|
||||
final FullHttpRequest copiedRequest;
|
||||
try {
|
||||
final FullHttpRequest copiedRequest =
|
||||
new DefaultFullHttpRequest(
|
||||
request.protocolVersion(),
|
||||
request.method(),
|
||||
request.uri(),
|
||||
Unpooled.copiedBuffer(request.content()),
|
||||
request.headers(),
|
||||
request.trailingHeaders());
|
||||
|
||||
NioHttpRequest httpRequest = new NioHttpRequest(copiedRequest, pipelinedRequest.getSequence());
|
||||
|
||||
if (request.decoderResult().isFailure()) {
|
||||
Throwable cause = request.decoderResult().cause();
|
||||
if (cause instanceof Error) {
|
||||
ExceptionsHelper.maybeDieOnAnotherThread(cause);
|
||||
transport.incomingRequestError(httpRequest, nioHttpChannel, new Exception(cause));
|
||||
} else {
|
||||
transport.incomingRequestError(httpRequest, nioHttpChannel, (Exception) cause);
|
||||
}
|
||||
} else {
|
||||
transport.incomingRequest(httpRequest, nioHttpChannel);
|
||||
}
|
||||
copiedRequest = new DefaultFullHttpRequest(
|
||||
request.protocolVersion(),
|
||||
request.method(),
|
||||
request.uri(),
|
||||
Unpooled.copiedBuffer(request.content()),
|
||||
request.headers(),
|
||||
request.trailingHeaders());
|
||||
} finally {
|
||||
// As we have copied the buffer, we can release the request
|
||||
request.release();
|
||||
}
|
||||
NioHttpRequest httpRequest = new NioHttpRequest(copiedRequest, pipelinedRequest.getSequence());
|
||||
|
||||
if (request.decoderResult().isFailure()) {
|
||||
Throwable cause = request.decoderResult().cause();
|
||||
if (cause instanceof Error) {
|
||||
ExceptionsHelper.maybeDieOnAnotherThread(cause);
|
||||
transport.incomingRequestError(httpRequest, nioHttpChannel, new Exception(cause));
|
||||
} else {
|
||||
transport.incomingRequestError(httpRequest, nioHttpChannel, (Exception) cause);
|
||||
}
|
||||
} else {
|
||||
transport.incomingRequest(httpRequest, nioHttpChannel);
|
||||
}
|
||||
}
|
||||
|
||||
private void maybeReadTimeout() {
|
||||
|
|
Loading…
Reference in New Issue