Fixed byte buffer leak in Netty4 request handler
If creating the REST request throws an exception (for example, because of invalid headers), we leak the request due to failure to release the buffer (which would otherwise happen after replying on the channel). This commit addresses this leak by handling the failure case. Relates #27222
This commit is contained in:
parent
827ba7f82d
commit
f9e755f980
|
@ -64,7 +64,15 @@ class Netty4HttpRequestHandler extends SimpleChannelInboundHandler<Object> {
|
|||
Unpooled.copiedBuffer(request.content()),
|
||||
request.headers(),
|
||||
request.trailingHeaders());
|
||||
final Netty4HttpRequest httpRequest = new Netty4HttpRequest(serverTransport.xContentRegistry, copy, ctx.channel());
|
||||
final Netty4HttpRequest httpRequest;
|
||||
try {
|
||||
httpRequest = new Netty4HttpRequest(serverTransport.xContentRegistry, copy, ctx.channel());
|
||||
} catch (Exception ex) {
|
||||
if (pipelinedRequest != null) {
|
||||
pipelinedRequest.release();
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
final Netty4HttpChannel channel =
|
||||
new Netty4HttpChannel(serverTransport, httpRequest, pipelinedRequest, detailedErrorsEnabled, threadContext);
|
||||
|
||||
|
|
Loading…
Reference in New Issue