Skip to content

Commit 837dba0

Browse files
committed
Use leak-tracking recycler in InboundPipelineTests
Today we use a leaky `NON_RECYCLING_INSTANCE` in `InboundPipelineTests#testPipelineHandling`. It's actually fine, we don't use it for anything important, but it looks suspicious and it means that a little bit of harmless-looking reordering would seriously affect the coverage of these tests. This commit gets rid of it to ensure that we're always watching for leaks. Noticed when reviewing elastic#80656.
1 parent 8da1236 commit 837dba0

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

server/src/test/java/org/elasticsearch/transport/InboundPipelineTests.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.elasticsearch.common.io.stream.RecyclerBytesStreamOutput;
2020
import org.elasticsearch.common.settings.Settings;
2121
import org.elasticsearch.common.util.MockPageCacheRecycler;
22-
import org.elasticsearch.common.util.PageCacheRecycler;
2322
import org.elasticsearch.common.util.concurrent.ThreadContext;
2423
import org.elasticsearch.core.Releasable;
2524
import org.elasticsearch.core.TimeValue;
@@ -93,7 +92,6 @@ public void testPipelineHandling() throws IOException {
9392
long totalMessages = 0;
9493
long bytesReceived = 0;
9594

96-
final BytesRefRecycler recycler = new BytesRefRecycler(PageCacheRecycler.NON_RECYCLING_INSTANCE);
9795
for (int i = 0; i < iterations; ++i) {
9896
actual.clear();
9997
expected.clear();
@@ -148,8 +146,9 @@ public void testPipelineHandling() throws IOException {
148146
}
149147

150148
expected.add(new Tuple<>(messageData, expectedExceptionClass));
151-
final BytesReference reference = message.serialize(new RecyclerBytesStreamOutput(recycler));
152-
Streams.copy(reference.streamInput(), streamOutput, false);
149+
try (RecyclerBytesStreamOutput temporaryOutput = new RecyclerBytesStreamOutput(recycler)) {
150+
Streams.copy(message.serialize(temporaryOutput).streamInput(), streamOutput, false);
151+
}
153152
}
154153

155154
final BytesReference networkBytes = streamOutput.bytes();

0 commit comments

Comments
 (0)