* 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) {
|
protected void channelRead0(ChannelHandlerContext ctx, HttpPipelinedRequest<FullHttpRequest> msg) {
|
||||||
Netty4HttpChannel channel = ctx.channel().attr(Netty4HttpServerTransport.HTTP_CHANNEL_KEY).get();
|
Netty4HttpChannel channel = ctx.channel().attr(Netty4HttpServerTransport.HTTP_CHANNEL_KEY).get();
|
||||||
FullHttpRequest request = msg.getRequest();
|
FullHttpRequest request = msg.getRequest();
|
||||||
|
final FullHttpRequest copiedRequest;
|
||||||
try {
|
try {
|
||||||
final FullHttpRequest copiedRequest =
|
copiedRequest =
|
||||||
new DefaultFullHttpRequest(
|
new DefaultFullHttpRequest(
|
||||||
request.protocolVersion(),
|
request.protocolVersion(),
|
||||||
request.method(),
|
request.method(),
|
||||||
|
@ -51,24 +51,23 @@ class Netty4HttpRequestHandler extends SimpleChannelInboundHandler<HttpPipelined
|
||||||
Unpooled.copiedBuffer(request.content()),
|
Unpooled.copiedBuffer(request.content()),
|
||||||
request.headers(),
|
request.headers(),
|
||||||
request.trailingHeaders());
|
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 {
|
} finally {
|
||||||
// As we have copied the buffer, we can release the request
|
// As we have copied the buffer, we can release the request
|
||||||
request.release();
|
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
|
@Override
|
||||||
|
|
|
@ -159,33 +159,32 @@ public class HttpReadWriteHandler implements NioChannelHandler {
|
||||||
final HttpPipelinedRequest<FullHttpRequest> pipelinedRequest = (HttpPipelinedRequest<FullHttpRequest>) msg;
|
final HttpPipelinedRequest<FullHttpRequest> pipelinedRequest = (HttpPipelinedRequest<FullHttpRequest>) msg;
|
||||||
FullHttpRequest request = pipelinedRequest.getRequest();
|
FullHttpRequest request = pipelinedRequest.getRequest();
|
||||||
|
|
||||||
|
final FullHttpRequest copiedRequest;
|
||||||
try {
|
try {
|
||||||
final FullHttpRequest copiedRequest =
|
copiedRequest = new DefaultFullHttpRequest(
|
||||||
new DefaultFullHttpRequest(
|
request.protocolVersion(),
|
||||||
request.protocolVersion(),
|
request.method(),
|
||||||
request.method(),
|
request.uri(),
|
||||||
request.uri(),
|
Unpooled.copiedBuffer(request.content()),
|
||||||
Unpooled.copiedBuffer(request.content()),
|
request.headers(),
|
||||||
request.headers(),
|
request.trailingHeaders());
|
||||||
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);
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
// As we have copied the buffer, we can release the request
|
// As we have copied the buffer, we can release the request
|
||||||
request.release();
|
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() {
|
private void maybeReadTimeout() {
|
||||||
|
|
Loading…
Reference in New Issue