From 0fb733f32ad6b08ccceb5d5c0e01df2c95d44d37 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Thu, 13 Jan 2022 13:17:32 +0100 Subject: [PATCH] Fixes #7209 - Flaky test GoAwayTest.testServerGoAwayWithStalledStreamServerConsumesDataOfInFlightStream() Signed-off-by: Simone Bordet --- .../org/eclipse/jetty/http2/client/GoAwayTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/GoAwayTest.java b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/GoAwayTest.java index 96038d38866..adc696e35cc 100644 --- a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/GoAwayTest.java +++ b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/GoAwayTest.java @@ -44,6 +44,7 @@ import org.eclipse.jetty.http2.frames.DataFrame; import org.eclipse.jetty.http2.frames.GoAwayFrame; import org.eclipse.jetty.http2.frames.HeadersFrame; import org.eclipse.jetty.http2.frames.ResetFrame; +import org.eclipse.jetty.http2.frames.SettingsFrame; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.FuturePromise; @@ -423,10 +424,17 @@ public class GoAwayTest extends AbstractTest h2.setInitialStreamRecvWindow(flowControlWindow); }); + CountDownLatch clientSettingsLatch = new CountDownLatch(1); CountDownLatch clientGoAwayLatch = new CountDownLatch(1); CountDownLatch clientCloseLatch = new CountDownLatch(1); Session clientSession = newClient(new Session.Listener.Adapter() { + @Override + public void onSettings(Session session, SettingsFrame frame) + { + clientSettingsLatch.countDown(); + } + @Override public void onGoAway(Session session, GoAwayFrame frame) { @@ -439,6 +447,12 @@ public class GoAwayTest extends AbstractTest clientCloseLatch.countDown(); } }); + + // Wait for the server settings to be received by the client. + // In particular, we want to wait for the initial stream flow + // control window setting before we create the first stream below. + Assertions.assertTrue(clientSettingsLatch.await(5, TimeUnit.SECONDS)); + // This is necessary because the server session window is smaller than the // default and the server cannot send a WINDOW_UPDATE with a negative value. ((ISession)clientSession).updateSendWindow(flowControlWindow - FlowControlStrategy.DEFAULT_WINDOW_SIZE);