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:
Norman Maurer 2019-06-29 09:21:11 +02:00 committed by GitHub
parent ee8206cb26
commit 47eb9c3bf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 {