Fix testStreamIsNotCreatedIfParentConnectionIsClosedConcurrently test (#10472)

Motivation:

testStreamIsNotCreatedIfParentConnectionIsClosedConcurrently() made some assumptions about sequencing which may not be true all the time and racy.

Modifications:

Fix the testcase so its not racy anymore

Result:

Fix build failure on master branch
This commit is contained in:
Norman Maurer 2020-08-12 07:09:00 +02:00 committed by GitHub
parent adcffb6260
commit 58654fff7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -95,28 +95,13 @@ public class Http2StreamChannelBootstrapTest {
clientChannel = cb.connect(serverAddress).sync().channel();
assertTrue(serverChannelLatch.await(3, SECONDS));
final CountDownLatch closeLatch = new CountDownLatch(1);
final Channel clientChannelToClose = clientChannel;
group.execute(new Runnable() {
@Override
public void run() {
try {
closeLatch.await();
clientChannelToClose.close().syncUninterruptibly();
} catch (InterruptedException e) {
logger.error(e);
}
}
});
Http2StreamChannelBootstrap bootstrap = new Http2StreamChannelBootstrap(clientChannel);
Promise<Http2StreamChannel> promise = clientChannel.eventLoop().newPromise();
clientChannel.close().sync();
bootstrap.open(promise);
assertThat(promise.isDone(), is(false));
closeLatch.countDown();
exceptionRule.expect(ExecutionException.class);
exceptionRule.expectCause(IsInstanceOf.<Throwable>instanceOf(ClosedChannelException.class));
exceptionRule.expectCause(IsInstanceOf.instanceOf(ClosedChannelException.class));
promise.get(3, SECONDS);
} finally {
safeClose(clientChannel);