File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
spring-boot-project/spring-boot/src/test/java/org/springframework/boot Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 1616
1717package org .springframework .boot ;
1818
19+ import java .time .Duration ;
1920import java .util .ArrayList ;
2021import java .util .Collections ;
2122import java .util .HashMap ;
3132
3233import jakarta .annotation .PostConstruct ;
3334import org .assertj .core .api .Condition ;
35+ import org .awaitility .Awaitility ;
3436import org .junit .jupiter .api .AfterEach ;
3537import org .junit .jupiter .api .BeforeEach ;
3638import org .junit .jupiter .api .Test ;
@@ -1423,7 +1425,11 @@ void shouldStopKeepAliveThreadIfContextIsClosed() {
14231425 assertThat (threadsBeforeClose ).filteredOn ((thread ) -> thread .getName ().equals ("keep-alive" )).isNotEmpty ();
14241426 this .context .close ();
14251427 Set <Thread > threadsAfterClose = getCurrentThreads ();
1426- assertThat (threadsAfterClose ).filteredOn ((thread ) -> thread .getName ().equals ("keep-alive" )).isEmpty ();
1428+ Awaitility .await ()
1429+ .atMost (Duration .ofSeconds (30 ))
1430+ .untilAsserted (
1431+ () -> assertThat (threadsAfterClose ).filteredOn ((thread ) -> thread .getName ().equals ("keep-alive" ))
1432+ .isEmpty ());
14271433 }
14281434
14291435 private <S extends AvailabilityState > ArgumentMatcher <ApplicationEvent > isAvailabilityChangeEventWithState (
You can’t perform that action at this time.
0 commit comments