Skip to content

Commit edd1564

Browse files
committed
Check available processors in ParallelApplicationEventsIntegrationTests
This commit changes the condition in the if-block to check the number of available processors instead of currently active threads with the hope that doing so will prove more reliable on the CI server.
1 parent 53cafe7 commit edd1564

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

spring-test/src/test/java/org/springframework/test/context/junit/jupiter/event/ParallelApplicationEventsIntegrationTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ void executeTestsInParallel(Class<?> testClass) {
7676
assertThat(payloads).hasSize(10);
7777
assertThat(testNames).hasSize(10);
7878

79-
// Skip the following assertion entirely if the thread count is too low.
80-
if (ManagementFactory.getThreadMXBean().getThreadCount() >= 4) {
79+
// Skip the following assertion entirely if too few processors are available
80+
// to the current JVM.
81+
if (Runtime.getRuntime().availableProcessors() >= 4) {
8182
// There are probably 10 different thread names on a developer's machine,
8283
// but we really just want to assert that at least two different threads
8384
// were used, since the CI server often has fewer threads available.

0 commit comments

Comments
 (0)