From 0a98a37cb6f7e7fb9059910058ea5ff46836a281 Mon Sep 17 00:00:00 2001 From: Ludovic Orban Date: Wed, 4 Aug 2021 10:57:09 +0200 Subject: [PATCH] #6327 wait for the request to be committed before sending the data Signed-off-by: Ludovic Orban --- .../http/client/HttpClientStreamTest.java | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientStreamTest.java b/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientStreamTest.java index a4f3b800895..6e49d148f4b 100644 --- a/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientStreamTest.java +++ b/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientStreamTest.java @@ -678,29 +678,22 @@ public class HttpClientStreamTest extends AbstractTest } }); - CountDownLatch demandLatch = new CountDownLatch(2); - CountDownLatch requestLatch = new CountDownLatch(1); - try (AsyncRequestContent content = new AsyncRequestContent() - { - @Override - public void demand() - { - demandLatch.countDown(); - super.demand(); - } - }) + CountDownLatch requestSentLatch = new CountDownLatch(1); + CountDownLatch responseLatch = new CountDownLatch(1); + try (AsyncRequestContent content = new AsyncRequestContent()) { scenario.client.newRequest(scenario.newURI()) .scheme(scenario.getScheme()) .body(content) + .onRequestCommit((request) -> requestSentLatch.countDown()) .send(result -> { if (result.isSucceeded() && result.getResponse().getStatus() == 200) - requestLatch.countDown(); + responseLatch.countDown(); }); // Make sure we provide the content *after* the request has been "sent". - assertTrue(demandLatch.await(5, TimeUnit.SECONDS)); + assertTrue(requestSentLatch.await(5, TimeUnit.SECONDS)); try (ByteArrayInputStream input = new ByteArrayInputStream(new byte[1024])) { @@ -712,7 +705,7 @@ public class HttpClientStreamTest extends AbstractTest } } } - assertTrue(requestLatch.await(5, TimeUnit.SECONDS)); + assertTrue(responseLatch.await(5, TimeUnit.SECONDS)); } @ParameterizedTest