Skip to content

Commit

Permalink
Release pipelined request in netty server tests (#32368)
Browse files Browse the repository at this point in the history
The Netty4HttpServerPipeliningTests adds a different request handler to
the netty pipeline. This request does not properly release pipelined
request. This means that when we enable leak detection, the test fails.
This commit properly releases the request.
  • Loading branch information
Tim-Brooks authored and jasontedor committed Aug 30, 2018
1 parent 138466e commit b28044c
Showing 1 changed file with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import io.netty.handler.codec.http.HttpResponseStatus;
import io.netty.handler.codec.http.HttpVersion;
import io.netty.util.ReferenceCounted;
import org.apache.lucene.util.LuceneTestCase.AwaitsFix;
import org.elasticsearch.common.network.NetworkService;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
Expand Down Expand Up @@ -122,7 +121,6 @@ public void testThatHttpPipeliningWorksWhenEnabled() throws Exception {
assertSettingDeprecationsAndWarnings(new Setting<?>[] {HttpTransportSettings.SETTING_PIPELINING});
}

@AwaitsFix(bugUrl="https://github.com/elastic/elasticsearch/issues/32900")
public void testThatHttpPipeliningCanBeDisabled() throws Exception {
final Settings settings = Settings.builder()
.put("http.pipelining", false)
Expand Down Expand Up @@ -261,8 +259,7 @@ public void run() {

final ByteBuf buffer = Unpooled.copiedBuffer(uri, StandardCharsets.UTF_8);

final DefaultFullHttpResponse httpResponse =
new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK, buffer);
final FullHttpResponse httpResponse = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK, buffer);
httpResponse.headers().add(HttpHeaderNames.CONTENT_LENGTH, buffer.readableBytes());

final boolean slow = uri.matches("/slow/\\d+");
Expand All @@ -284,10 +281,7 @@ public void run() {
msg = httpResponse;
}
ctx.writeAndFlush(msg, promise);
} finally {
if (fullHttpRequest != null) {
fullHttpRequest.release();
}
} finally {
if (pipelinedRequest != null) {
pipelinedRequest.release();
}
Expand Down

0 comments on commit b28044c

Please sign in to comment.