Networking: Fix test leaking buffer (#32296)

* Test `handler` must release buffer the same way the replaced `org.elasticsearch.http.netty4.Netty4HttpRequestHandler#channelRead0` releases it
* Closes #32289
This commit is contained in:
Armin Braun 2018-07-24 23:04:22 +02:00 committed by GitHub
parent 54ba3ea286
commit 717df26fc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 16 deletions

View File

@ -181,12 +181,14 @@ public class Netty4HttpServerPipeliningTests extends ESTestCase {
@Override
public void run() {
try {
final String uri = fullHttpRequest.uri();
final ByteBuf buffer = Unpooled.copiedBuffer(uri, StandardCharsets.UTF_8);
Netty4HttpRequest httpRequest = new Netty4HttpRequest(fullHttpRequest, pipelinedRequest.getSequence());
Netty4HttpResponse response = httpRequest.createResponse(RestStatus.OK, new BytesArray(uri.getBytes(StandardCharsets.UTF_8)));
Netty4HttpResponse response =
httpRequest.createResponse(RestStatus.OK, new BytesArray(uri.getBytes(StandardCharsets.UTF_8)));
response.headers().add(HttpHeaderNames.CONTENT_LENGTH, buffer.readableBytes());
final boolean slow = uri.matches("/slow/\\d+");
@ -202,6 +204,9 @@ public class Netty4HttpServerPipeliningTests extends ESTestCase {
final ChannelPromise promise = ctx.newPromise();
ctx.writeAndFlush(response, promise);
} finally {
fullHttpRequest.release();
}
}
}