From edd15646af23f7d80785840cd77222151fc1486e Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 10 Feb 2021 12:02:32 +0100 Subject: [PATCH] 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. --- .../event/ParallelApplicationEventsIntegrationTests.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/event/ParallelApplicationEventsIntegrationTests.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/event/ParallelApplicationEventsIntegrationTests.java index 4dda66edfe..3c5cf649f5 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/event/ParallelApplicationEventsIntegrationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/event/ParallelApplicationEventsIntegrationTests.java @@ -76,8 +76,9 @@ class ParallelApplicationEventsIntegrationTests { assertThat(payloads).hasSize(10); assertThat(testNames).hasSize(10); - // Skip the following assertion entirely if the thread count is too low. - if (ManagementFactory.getThreadMXBean().getThreadCount() >= 4) { + // Skip the following assertion entirely if too few processors are available + // to the current JVM. + if (Runtime.getRuntime().availableProcessors() >= 4) { // There are probably 10 different thread names on a developer's machine, // but we really just want to assert that at least two different threads // were used, since the CI server often has fewer threads available.