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 16
16
17
17
package org .springframework .boot ;
18
18
19
+ import java .time .Duration ;
19
20
import java .util .ArrayList ;
20
21
import java .util .Collections ;
21
22
import java .util .HashMap ;
31
32
32
33
import jakarta .annotation .PostConstruct ;
33
34
import org .assertj .core .api .Condition ;
35
+ import org .awaitility .Awaitility ;
34
36
import org .junit .jupiter .api .AfterEach ;
35
37
import org .junit .jupiter .api .BeforeEach ;
36
38
import org .junit .jupiter .api .Test ;
@@ -1423,7 +1425,11 @@ void shouldStopKeepAliveThreadIfContextIsClosed() {
1423
1425
assertThat (threadsBeforeClose ).filteredOn ((thread ) -> thread .getName ().equals ("keep-alive" )).isNotEmpty ();
1424
1426
this .context .close ();
1425
1427
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 ());
1427
1433
}
1428
1434
1429
1435
private <S extends AvailabilityState > ArgumentMatcher <ApplicationEvent > isAvailabilityChangeEventWithState (
You can’t perform that action at this time.
0 commit comments