Add testcase to try to reproduce #2144
This commit is contained in:
parent
2b63d2d0cd
commit
cac449a5e4
@ -24,6 +24,7 @@ import io.netty.channel.ChannelHandlerContext;
|
|||||||
import io.netty.channel.ChannelInitializer;
|
import io.netty.channel.ChannelInitializer;
|
||||||
import io.netty.channel.DefaultEventLoopGroup;
|
import io.netty.channel.DefaultEventLoopGroup;
|
||||||
import io.netty.channel.EventLoopGroup;
|
import io.netty.channel.EventLoopGroup;
|
||||||
|
import io.netty.channel.SimpleChannelInboundHandler;
|
||||||
import io.netty.util.internal.logging.InternalLogger;
|
import io.netty.util.internal.logging.InternalLogger;
|
||||||
import io.netty.util.internal.logging.InternalLoggerFactory;
|
import io.netty.util.internal.logging.InternalLoggerFactory;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -144,6 +145,39 @@ public class LocalChannelTest {
|
|||||||
clientGroup.terminationFuture().sync();
|
clientGroup.terminationFuture().sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testServerCloseChannelSameEventLoop() throws Exception {
|
||||||
|
LocalAddress addr = new LocalAddress(LOCAL_ADDR_ID);
|
||||||
|
LocalEventLoopGroup group = new LocalEventLoopGroup(1);
|
||||||
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
ServerBootstrap sb = new ServerBootstrap()
|
||||||
|
.group(group)
|
||||||
|
.channel(LocalServerChannel.class)
|
||||||
|
.childHandler(new SimpleChannelInboundHandler<Object>() {
|
||||||
|
@Override
|
||||||
|
protected void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||||
|
ctx.close();
|
||||||
|
latch.countDown();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
sb.bind(addr).sync();
|
||||||
|
|
||||||
|
Bootstrap b = new Bootstrap()
|
||||||
|
.group(group)
|
||||||
|
.channel(LocalChannel.class)
|
||||||
|
.handler(new SimpleChannelInboundHandler<Object>() {
|
||||||
|
@Override
|
||||||
|
protected void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||||
|
// discard
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Channel channel = b.connect(addr).sync().channel();
|
||||||
|
channel.writeAndFlush(new Object());
|
||||||
|
latch.await();
|
||||||
|
group.shutdownGracefully();
|
||||||
|
group.terminationFuture().sync();
|
||||||
|
}
|
||||||
|
|
||||||
static class TestHandler extends ChannelHandlerAdapter {
|
static class TestHandler extends ChannelHandlerAdapter {
|
||||||
@Override
|
@Override
|
||||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user