From 9897576562b65f93c8ab4523ded7b1aa9785fd45 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 20 Oct 2023 12:57:17 +0100 Subject: [PATCH] Polish d22969ae The current threads must be retrieved each time so that we can see the keep-alive thread dying. See gh-37736 --- .../org/springframework/boot/SpringApplicationTests.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java index 275ad5a2735..92eefe0e3fe 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java @@ -1421,15 +1421,12 @@ class SpringApplicationTests { application.setWebApplicationType(WebApplicationType.NONE); application.setKeepAlive(true); this.context = application.run(); - Set threadsBeforeClose = getCurrentThreads(); - assertThat(threadsBeforeClose).filteredOn((thread) -> thread.getName().equals("keep-alive")).isNotEmpty(); + assertThat(getCurrentThreads()).filteredOn((thread) -> thread.getName().equals("keep-alive")).isNotEmpty(); this.context.close(); - Set threadsAfterClose = getCurrentThreads(); Awaitility.await() .atMost(Duration.ofSeconds(30)) - .untilAsserted( - () -> assertThat(threadsAfterClose).filteredOn((thread) -> thread.getName().equals("keep-alive")) - .isEmpty()); + .untilAsserted(() -> assertThat(getCurrentThreads()) + .filteredOn((thread) -> thread.getName().equals("keep-alive"))); } private ArgumentMatcher isAvailabilityChangeEventWithState(