Skip to content

Commit

Permalink
Fix SimpleChannelPoolTest#testCloseAsync() test flake (#9943)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
njhill authored and normanmaurer committed Jan 11, 2020
1 parent f7d3573 commit ba140ac
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit ba140ac

Please sign in to comment.