Skip to content

Commit c89430e

Browse files
committed
Try to stabilize httpConnectionsAreClosedAfterLongPollTimeout
Closes gh-26888
1 parent 7a14a53 commit c89430e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServerTests.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
import java.nio.ByteBuffer;
2323
import java.nio.channels.ByteChannel;
2424
import java.nio.channels.Channels;
25+
import java.time.Duration;
2526
import java.util.concurrent.BlockingDeque;
2627
import java.util.concurrent.LinkedBlockingDeque;
2728
import java.util.concurrent.TimeUnit;
2829
import java.util.concurrent.atomic.AtomicBoolean;
2930

31+
import org.awaitility.Awaitility;
3032
import org.junit.jupiter.api.BeforeEach;
3133
import org.junit.jupiter.api.Test;
3234
import org.junit.jupiter.api.extension.ExtendWith;
@@ -236,13 +238,14 @@ void httpConnectionsAreClosedAfterLongPollTimeout() throws Exception {
236238
this.server.setLongPollTimeout(100);
237239
MockHttpConnection h1 = new MockHttpConnection();
238240
this.server.handle(h1);
241+
Awaitility.await().atMost(Duration.ofSeconds(30)).until(h1.getServletResponse()::getStatus,
242+
(status) -> status == 204);
239243
MockHttpConnection h2 = new MockHttpConnection();
240244
this.server.handle(h2);
241-
Thread.sleep(400);
245+
Awaitility.await().atMost(Duration.ofSeconds(30)).until(h2.getServletResponse()::getStatus,
246+
(status) -> status == 204);
242247
this.serverChannel.disconnect();
243248
this.server.getServerThread().join();
244-
assertThat(h1.getServletResponse().getStatus()).isEqualTo(204);
245-
assertThat(h2.getServletResponse().getStatus()).isEqualTo(204);
246249
}
247250

248251
@Test

0 commit comments

Comments
 (0)