From e1c6f111f5ba8c280fe2aea8d1ce56e36d037dc3 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Thu, 3 Sep 2020 09:47:36 +0200 Subject: [PATCH] Call IOUringEventLoopGroup.shutdownGracefully() after test is done. --- .../netty/channel/uring/PollRemoveTest.java | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/PollRemoveTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/PollRemoveTest.java index fa3cae6a96..08f48993ac 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/PollRemoveTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/PollRemoveTest.java @@ -8,6 +8,7 @@ import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelPipeline; import io.netty.channel.EventLoopGroup; +import io.netty.channel.socket.ServerSocketChannel; import io.netty.channel.socket.SocketChannel; import io.netty.handler.logging.LogLevel; import io.netty.handler.logging.LoggingHandler; @@ -24,7 +25,7 @@ public class PollRemoveTest { } @Sharable - class EchoUringServerHandler extends ChannelInboundHandlerAdapter { + private static final class EchoUringServerHandler extends ChannelInboundHandlerAdapter { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) { @@ -46,29 +47,33 @@ public class PollRemoveTest { } void io_uring_test() throws Exception { - Class clazz; + Class clazz = IOUringServerSocketChannel.class; final EventLoopGroup bossGroup = new IOUringEventLoopGroup(1); final EventLoopGroup workerGroup = new IOUringEventLoopGroup(1); - clazz = IOUringServerSocketChannel.class; - ServerBootstrap b = new ServerBootstrap(); - b.group(bossGroup, workerGroup) - .channel(clazz) - .handler(new LoggingHandler(LogLevel.TRACE)) - .childHandler(new ChannelInitializer() { - @Override - public void initChannel(SocketChannel ch) throws Exception { - ChannelPipeline p = ch.pipeline(); + try { + ServerBootstrap b = new ServerBootstrap(); + b.group(bossGroup, workerGroup) + .channel(clazz) + .handler(new LoggingHandler(LogLevel.TRACE)) + .childHandler(new ChannelInitializer() { + @Override + public void initChannel(SocketChannel ch) throws Exception { + ChannelPipeline p = ch.pipeline(); - p.addLast(new EchoUringServerHandler()); - } - }); + p.addLast(new EchoUringServerHandler()); + } + }); - Channel sc = b.bind(2020).sync().channel(); - Thread.sleep(1500); + Channel sc = b.bind(2020).sync().channel(); + Thread.sleep(1500); - //close ServerChannel - sc.close().sync(); + // close ServerChannel + sc.close().sync(); + } finally { + bossGroup.shutdownGracefully(); + workerGroup.shutdownGracefully(); + } }