Skip to content

Commit c1f6aff

Browse files
committed
Remove default netty allocator empty assertions (#48356)
This commit removes a problematic assertion that the netty default allocator is not used. This assertion is problematic because any other test can cause this task to fail by touching the default allocator. We assert that we are using heap buffers in the channel.
1 parent e45b0cd commit c1f6aff

File tree

3 files changed

+6
-18
lines changed

3 files changed

+6
-18
lines changed

modules/transport-netty4/src/test/java/org/elasticsearch/ESNetty4IntegTestCase.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
*/
1919
package org.elasticsearch;
2020

21-
import io.netty.buffer.PooledByteBufAllocator;
2221
import org.elasticsearch.common.network.NetworkModule;
2322
import org.elasticsearch.common.settings.Settings;
2423
import org.elasticsearch.plugins.Plugin;
@@ -65,16 +64,8 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
6564
return Collections.singletonList(Netty4Plugin.class);
6665
}
6766

68-
@Override
69-
public void tearDown() throws Exception {
70-
super.tearDown();
71-
assertEquals(0, PooledByteBufAllocator.DEFAULT.metric().usedHeapMemory());
72-
assertEquals(0, PooledByteBufAllocator.DEFAULT.metric().usedDirectMemory());
73-
}
74-
7567
@Override
7668
protected Collection<Class<? extends Plugin>> transportClientPlugins() {
7769
return Collections.singletonList(Netty4Plugin.class);
7870
}
79-
8071
}

modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpServerTransportTests.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import io.netty.channel.ChannelFuture;
2626
import io.netty.channel.ChannelHandlerAdapter;
2727
import io.netty.channel.ChannelInitializer;
28+
import io.netty.channel.ChannelOption;
2829
import io.netty.channel.nio.NioEventLoopGroup;
2930
import io.netty.channel.socket.SocketChannel;
3031
import io.netty.channel.socket.nio.NioSocketChannel;
@@ -61,6 +62,7 @@
6162
import org.elasticsearch.test.ESTestCase;
6263
import org.elasticsearch.threadpool.TestThreadPool;
6364
import org.elasticsearch.threadpool.ThreadPool;
65+
import org.elasticsearch.transport.NettyAllocator;
6466
import org.junit.After;
6567
import org.junit.Before;
6668

@@ -348,7 +350,10 @@ public void dispatchBadRequest(final RestChannel channel,
348350

349351
CountDownLatch channelClosedLatch = new CountDownLatch(1);
350352

351-
Bootstrap clientBootstrap = new Bootstrap().channel(NioSocketChannel.class).handler(new ChannelInitializer<SocketChannel>() {
353+
Bootstrap clientBootstrap = new Bootstrap()
354+
.option(ChannelOption.ALLOCATOR, NettyAllocator.getAllocator())
355+
.channel(NioSocketChannel.class)
356+
.handler(new ChannelInitializer<SocketChannel>() {
352357

353358
@Override
354359
protected void initChannel(SocketChannel ch) {

modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/SimpleNetty4TransportTests.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
package org.elasticsearch.transport.netty4;
2121

22-
import io.netty.buffer.PooledByteBufAllocator;
2322
import org.elasticsearch.Version;
2423
import org.elasticsearch.action.ActionListener;
2524
import org.elasticsearch.cluster.node.DiscoveryNode;
@@ -46,13 +45,6 @@
4645

4746
public class SimpleNetty4TransportTests extends AbstractSimpleTransportTestCase {
4847

49-
@Override
50-
public void tearDown() throws Exception {
51-
super.tearDown();
52-
assertEquals(0, PooledByteBufAllocator.DEFAULT.metric().usedHeapMemory());
53-
assertEquals(0, PooledByteBufAllocator.DEFAULT.metric().usedDirectMemory());
54-
}
55-
5648
@Override
5749
protected Transport build(Settings settings, final Version version, ClusterSettings clusterSettings, boolean doHandshake) {
5850
NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(Collections.emptyList());

0 commit comments

Comments
 (0)