From c89430e174e547b9efd92cac670665b56f3df243 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 14 Jun 2021 11:04:23 +0100 Subject: [PATCH] Try to stabilize httpConnectionsAreClosedAfterLongPollTimeout Closes gh-26888 --- .../devtools/tunnel/server/HttpTunnelServerTests.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServerTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServerTests.java index a299cc3eea0..a8bae90caeb 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServerTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServerTests.java @@ -22,11 +22,13 @@ import java.net.SocketTimeoutException; import java.nio.ByteBuffer; import java.nio.channels.ByteChannel; import java.nio.channels.Channels; +import java.time.Duration; import java.util.concurrent.BlockingDeque; import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; +import org.awaitility.Awaitility; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -236,13 +238,14 @@ class HttpTunnelServerTests { this.server.setLongPollTimeout(100); MockHttpConnection h1 = new MockHttpConnection(); this.server.handle(h1); + Awaitility.await().atMost(Duration.ofSeconds(30)).until(h1.getServletResponse()::getStatus, + (status) -> status == 204); MockHttpConnection h2 = new MockHttpConnection(); this.server.handle(h2); - Thread.sleep(400); + Awaitility.await().atMost(Duration.ofSeconds(30)).until(h2.getServletResponse()::getStatus, + (status) -> status == 204); this.serverChannel.disconnect(); this.server.getServerThread().join(); - assertThat(h1.getServletResponse().getStatus()).isEqualTo(204); - assertThat(h2.getServletResponse().getStatus()).isEqualTo(204); } @Test