Skip to content

Commit 940d969

Browse files
polarbear567snicoll
authored andcommitted
Use a timeout when joining threads in HttpTunnelServerTests
See gh-29522
1 parent 458f672 commit 940d969

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ void initialRequestIsSentToServer() throws Exception {
130130
this.servletRequest.setContent("hello".getBytes());
131131
this.server.handle(this.request, this.response);
132132
this.serverChannel.disconnect();
133-
this.server.getServerThread().join();
133+
this.server.getServerThread().join(2000);
134134
this.serverChannel.verifyReceived("hello");
135135
}
136136

@@ -143,7 +143,7 @@ void initialRequestIsUsedForFirstServerResponse() throws Exception {
143143
System.out.println("sending");
144144
this.serverChannel.send("hello");
145145
this.serverChannel.disconnect();
146-
this.server.getServerThread().join();
146+
this.server.getServerThread().join(2000);
147147
assertThat(this.servletResponse.getContentAsString()).isEqualTo("hello");
148148
this.serverChannel.verifyReceived("hello");
149149
}
@@ -153,7 +153,7 @@ void initialRequestHasNoPayload() throws Exception {
153153
givenServerConnectionOpenWillAnswerWithServerChannel();
154154
this.server.handle(this.request, this.response);
155155
this.serverChannel.disconnect();
156-
this.server.getServerThread().join();
156+
this.server.getServerThread().join(2000);
157157
this.serverChannel.verifyReceived(NO_DATA);
158158
}
159159

@@ -176,7 +176,7 @@ void typicalRequestResponseTraffic() throws Exception {
176176
this.serverChannel.send("=3");
177177
h3.verifyReceived("=3", 3);
178178
this.serverChannel.disconnect();
179-
this.server.getServerThread().join();
179+
this.server.getServerThread().join(2000);
180180
}
181181

182182
@Test
@@ -185,7 +185,7 @@ void clientIsAwareOfServerClose() throws Exception {
185185
MockHttpConnection h1 = new MockHttpConnection("1", 1);
186186
this.server.handle(h1);
187187
this.serverChannel.disconnect();
188-
this.server.getServerThread().join();
188+
this.server.getServerThread().join(2000);
189189
assertThat(h1.getServletResponse().getStatus()).isEqualTo(410);
190190
}
191191

@@ -197,7 +197,7 @@ void clientCanCloseServer() throws Exception {
197197
MockHttpConnection h2 = new MockHttpConnection("DISCONNECT", 1);
198198
h2.getServletRequest().addHeader("Content-Type", "application/x-disconnect");
199199
this.server.handle(h2);
200-
this.server.getServerThread().join();
200+
this.server.getServerThread().join(2000);
201201
assertThat(h1.getServletResponse().getStatus()).isEqualTo(410);
202202
assertThat(this.serverChannel.isOpen()).isFalse();
203203
}
@@ -214,7 +214,7 @@ void neverMoreThanTwoHttpConnections() throws Exception {
214214
h1.waitForResponse();
215215
assertThat(h1.getServletResponse().getStatus()).isEqualTo(429);
216216
this.serverChannel.disconnect();
217-
this.server.getServerThread().join();
217+
this.server.getServerThread().join(2000);
218218
}
219219

220220
@Test
@@ -228,7 +228,7 @@ void requestReceivedOutOfOrder() throws Exception {
228228
this.server.handle(h2);
229229
this.serverChannel.verifyReceived("1+2+3");
230230
this.serverChannel.disconnect();
231-
this.server.getServerThread().join();
231+
this.server.getServerThread().join(2000);
232232
}
233233

234234
@Test
@@ -245,7 +245,7 @@ void httpConnectionsAreClosedAfterLongPollTimeout() throws Exception {
245245
Awaitility.await().atMost(Duration.ofSeconds(30)).until(h2.getServletResponse()::getStatus,
246246
(status) -> status == 204);
247247
this.serverChannel.disconnect();
248-
this.server.getServerThread().join();
248+
this.server.getServerThread().join(2000);
249249
}
250250

251251
@Test
@@ -256,7 +256,7 @@ void disconnectTimeout() throws Exception {
256256
MockHttpConnection h1 = new MockHttpConnection();
257257
this.server.handle(h1);
258258
this.serverChannel.send("hello");
259-
this.server.getServerThread().join();
259+
this.server.getServerThread().join(2000);
260260
assertThat(this.serverChannel.isOpen()).isFalse();
261261
}
262262

0 commit comments

Comments
 (0)