diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionRoundtripTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionRoundtripTest.java index 32febac05f..4ef4dc6306 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionRoundtripTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionRoundtripTest.java @@ -522,18 +522,7 @@ public class Http2ConnectionRoundtripTest { final CountDownLatch serverWriteHeadersLatch = new CountDownLatch(1); final AtomicReference serverWriteHeadersCauseRef = new AtomicReference(); - final Http2Headers headers = dummyHeaders(); final int streamId = 3; - runInChannel(clientChannel, new Http2Runnable() { - @Override - public void run() throws Http2Exception { - http2Client.encoder().writeHeaders(ctx(), streamId, headers, CONNECTION_STREAM_ID, - DEFAULT_PRIORITY_WEIGHT, false, 0, false, newPromise()); - http2Client.encoder().writeRstStream(ctx(), streamId, Http2Error.CANCEL.code(), newPromise()); - http2Client.flush(ctx()); - } - }); - doAnswer(new Answer() { @Override public Void answer(InvocationOnMock invocationOnMock) throws Throwable { @@ -544,6 +533,17 @@ public class Http2ConnectionRoundtripTest { } }).when(serverListener).onRstStreamRead(any(ChannelHandlerContext.class), eq(streamId), anyLong()); + final Http2Headers headers = dummyHeaders(); + runInChannel(clientChannel, new Http2Runnable() { + @Override + public void run() throws Http2Exception { + http2Client.encoder().writeHeaders(ctx(), streamId, headers, CONNECTION_STREAM_ID, + DEFAULT_PRIORITY_WEIGHT, false, 0, false, newPromise()); + http2Client.encoder().writeRstStream(ctx(), streamId, Http2Error.CANCEL.code(), newPromise()); + http2Client.flush(ctx()); + } + }); + assertTrue(serverSettingsAckLatch.await(DEFAULT_AWAIT_TIMEOUT_SECONDS, SECONDS)); assertTrue(serverGotRstLatch.await(DEFAULT_AWAIT_TIMEOUT_SECONDS, SECONDS));