This is a bug… Just opened a PR to fix it:
https://github.com/netty/netty/pull/9030 <https://github.com/netty/netty/pull/9030> Thanks! > On 10. Apr 2019, at 12:19, Priyanka Perera <[email protected]> wrote: > > Hi all, > > What's the expected state of a server socket channel once the close() or > disconnect() is invoked ? > > Below code reports that server socket channel is still active even after the > close() future is sync'ed. > final EchoServerHandler serverHandler = new EchoServerHandler(); > EventLoopGroup group = new NioEventLoopGroup(); > ServerBootstrap serverBootstrap = new ServerBootstrap(); > serverBootstrap.group(group) > .channel(NioServerSocketChannel.class) > .localAddress(new InetSocketAddress(port)) > .childHandler(new ChannelInitializer<SocketChannel>(){ > @Override > public void initChannel(SocketChannel ch) > throws Exception { > ch.pipeline().addLast(serverHandler); > } > }); > > ChannelFuture channelFuture = serverBootstrap.bind().sync(); > System.out.println("Server started"); > Thread.sleep(5000); > Assert.assertTrue(channelFuture.channel().close().sync().isSuccess()); > Assert.assertFalse(channelFuture.channel().isActive(), "Channel is active"); > > It fails on the last assertion with > > Exception in thread "Thread-0" java.lang.AssertionError: Channel is active > expected [false] but found [true] > at org.testng.Assert.fail(Assert.java:94) > at org.testng.Assert.failNotEquals(Assert.java:513) > at org.testng.Assert.assertFalse(Assert.java:63) > at EchoServer.start(EchoServer.java:43) > > at ServerStarter.run(NettyTest.java:21) > at java.lang.Thread.run(Thread.java:748) > > What's the rational behind it ? > > Thanks > Priyanka > > -- > You received this message because you are subscribed to the Google Groups > "Netty discussions" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/netty/CAJt14FMPjfej0ShgoMpC_AUWYGVCdQNva4OjzHtPC6eQSKf__g%40mail.gmail.com > > <https://groups.google.com/d/msgid/netty/CAJt14FMPjfej0ShgoMpC_AUWYGVCdQNva4OjzHtPC6eQSKf__g%40mail.gmail.com?utm_medium=email&utm_source=footer>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- You received this message because you are subscribed to the Google Groups "Netty discussions" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/netty/F461D4B6-5FF1-4E03-BC95-D6B369B80010%40googlemail.com. For more options, visit https://groups.google.com/d/optout.
