From ba140ac6bcf24fdd90d1231ee397ba5a204c17e8 Mon Sep 17 00:00:00 2001 From: Nick Hill Date: Fri, 10 Jan 2020 21:03:46 -0800 Subject: [PATCH] Fix SimpleChannelPoolTest#testCloseAsync() test flake (#9943) Motivation This test is failing intermittently and upon inspection has a race condition. Modification Fix race condition by waiting for async release calls to complete prior to closing the pool. Result Hopefully fixed flakey test --- .../java/io/netty/channel/pool/SimpleChannelPoolTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/transport/src/test/java/io/netty/channel/pool/SimpleChannelPoolTest.java b/transport/src/test/java/io/netty/channel/pool/SimpleChannelPoolTest.java index 3225c74e2d5..debb9df5ef5 100644 --- a/transport/src/test/java/io/netty/channel/pool/SimpleChannelPoolTest.java +++ b/transport/src/test/java/io/netty/channel/pool/SimpleChannelPoolTest.java @@ -334,8 +334,8 @@ protected void initChannel(LocalChannel ch) throws Exception { final SimpleChannelPool pool = new SimpleChannelPool(bootstrap, new CountingChannelPoolHandler()); Channel ch1 = pool.acquire().syncUninterruptibly().getNow(); Channel ch2 = pool.acquire().syncUninterruptibly().getNow(); - pool.release(ch1); - pool.release(ch2); + pool.release(ch1).get(1, TimeUnit.SECONDS); + pool.release(ch2).get(1, TimeUnit.SECONDS); // Assert that returned channels are open before close assertTrue(ch1.isOpen());