Ensure sc.close() is executed before FixedChannelPoolTest.testCloseAsync() returns (#9298)
Motivation: We observed some test-failues sometimes in the CI which happened if sc.close() was not completed before the next test did run. If this happened we would fail the bind(...) as the LocalAddress was still in use. Modifications: Await the close before return Result: Fixes race in testsuite which resulted in FixedChannelPoolTest.testAcquireNewConnection to fail if FixedChannelPoolTest.testCloseAsync() did run before it.
This commit is contained in:
parent
ee8206cb26
commit
47eb9c3bf4
@ -20,6 +20,7 @@ import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.channel.DefaultEventLoopGroup;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.local.LocalAddress;
|
||||
@ -374,13 +375,15 @@ public class FixedChannelPoolTest {
|
||||
pool.acquire().get();
|
||||
pool.acquire().get();
|
||||
|
||||
final ChannelPromise closePromise = sc.newPromise();
|
||||
pool.closeAsync().addListener(new GenericFutureListener<Future<? super Void>>() {
|
||||
@Override
|
||||
public void operationComplete(Future<? super Void> future) throws Exception {
|
||||
Assert.assertEquals(0, pool.acquiredChannelCount());
|
||||
sc.close().syncUninterruptibly();
|
||||
sc.close(closePromise).syncUninterruptibly();
|
||||
}
|
||||
}).awaitUninterruptibly();
|
||||
closePromise.awaitUninterruptibly();
|
||||
}
|
||||
|
||||
private static final class TestChannelPoolHandler extends AbstractChannelPoolHandler {
|
||||
|
Loading…
Reference in New Issue
Block a user