Skip to content

Commit 9897576

Browse files
committed
Polish d22969a
The current threads must be retrieved each time so that we can see the keep-alive thread dying. See gh-37736
1 parent d13d38a commit 9897576

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,15 +1421,12 @@ void shouldStopKeepAliveThreadIfContextIsClosed() {
14211421
application.setWebApplicationType(WebApplicationType.NONE);
14221422
application.setKeepAlive(true);
14231423
this.context = application.run();
1424-
Set<Thread> threadsBeforeClose = getCurrentThreads();
1425-
assertThat(threadsBeforeClose).filteredOn((thread) -> thread.getName().equals("keep-alive")).isNotEmpty();
1424+
assertThat(getCurrentThreads()).filteredOn((thread) -> thread.getName().equals("keep-alive")).isNotEmpty();
14261425
this.context.close();
1427-
Set<Thread> threadsAfterClose = getCurrentThreads();
14281426
Awaitility.await()
14291427
.atMost(Duration.ofSeconds(30))
1430-
.untilAsserted(
1431-
() -> assertThat(threadsAfterClose).filteredOn((thread) -> thread.getName().equals("keep-alive"))
1432-
.isEmpty());
1428+
.untilAsserted(() -> assertThat(getCurrentThreads())
1429+
.filteredOn((thread) -> thread.getName().equals("keep-alive")));
14331430
}
14341431

14351432
private <S extends AvailabilityState> ArgumentMatcher<ApplicationEvent> isAvailabilityChangeEventWithState(

0 commit comments

Comments
 (0)