mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Polish d22969ae
The current threads must be retrieved each time so that we can see the keep-alive thread dying. See gh-37736
This commit is contained in:
parent
d13d38a141
commit
9897576562
@ -1421,15 +1421,12 @@ class SpringApplicationTests {
|
|||||||
application.setWebApplicationType(WebApplicationType.NONE);
|
application.setWebApplicationType(WebApplicationType.NONE);
|
||||||
application.setKeepAlive(true);
|
application.setKeepAlive(true);
|
||||||
this.context = application.run();
|
this.context = application.run();
|
||||||
Set<Thread> threadsBeforeClose = getCurrentThreads();
|
assertThat(getCurrentThreads()).filteredOn((thread) -> thread.getName().equals("keep-alive")).isNotEmpty();
|
||||||
assertThat(threadsBeforeClose).filteredOn((thread) -> thread.getName().equals("keep-alive")).isNotEmpty();
|
|
||||||
this.context.close();
|
this.context.close();
|
||||||
Set<Thread> threadsAfterClose = getCurrentThreads();
|
|
||||||
Awaitility.await()
|
Awaitility.await()
|
||||||
.atMost(Duration.ofSeconds(30))
|
.atMost(Duration.ofSeconds(30))
|
||||||
.untilAsserted(
|
.untilAsserted(() -> assertThat(getCurrentThreads())
|
||||||
() -> assertThat(threadsAfterClose).filteredOn((thread) -> thread.getName().equals("keep-alive"))
|
.filteredOn((thread) -> thread.getName().equals("keep-alive")));
|
||||||
.isEmpty());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private <S extends AvailabilityState> ArgumentMatcher<ApplicationEvent> isAvailabilityChangeEventWithState(
|
private <S extends AvailabilityState> ArgumentMatcher<ApplicationEvent> isAvailabilityChangeEventWithState(
|
||||||
|
Loading…
Reference in New Issue
Block a user