Skip to content

Commit 47eb9c3

Browse files
authored
Ensure sc.close() is executed before FixedChannelPoolTest.testCloseAsync() returns (netty#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.
1 parent ee8206c commit 47eb9c3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

transport/src/test/java/io/netty/channel/pool/FixedChannelPoolTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import io.netty.channel.Channel;
2121
import io.netty.channel.ChannelInboundHandlerAdapter;
2222
import io.netty.channel.ChannelInitializer;
23+
import io.netty.channel.ChannelPromise;
2324
import io.netty.channel.DefaultEventLoopGroup;
2425
import io.netty.channel.EventLoopGroup;
2526
import io.netty.channel.local.LocalAddress;
@@ -374,13 +375,15 @@ public void initChannel(LocalChannel ch) throws Exception {
374375
pool.acquire().get();
375376
pool.acquire().get();
376377

378+
final ChannelPromise closePromise = sc.newPromise();
377379
pool.closeAsync().addListener(new GenericFutureListener<Future<? super Void>>() {
378380
@Override
379381
public void operationComplete(Future<? super Void> future) throws Exception {
380382
Assert.assertEquals(0, pool.acquiredChannelCount());
381-
sc.close().syncUninterruptibly();
383+
sc.close(closePromise).syncUninterruptibly();
382384
}
383385
}).awaitUninterruptibly();
386+
closePromise.awaitUninterruptibly();
384387
}
385388

386389
private static final class TestChannelPoolHandler extends AbstractChannelPoolHandler {

0 commit comments

Comments
 (0)