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(