From 60e71463266542ab19dd6cf8360f298b0ddc3431 Mon Sep 17 00:00:00 2001 From: dreis2211 Date: Thu, 9 Jul 2020 19:04:56 +0200 Subject: [PATCH] Reduce started threads in OnClassCondition Prior to this commit, OnClassCondition started a thread even if the number of passed autoconfiguration class candidates never exceeded 1. This commit only starts a thread if there is actually work to split in half. See gh-22294 --- .../boot/autoconfigure/condition/OnClassCondition.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnClassCondition.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnClassCondition.java index 406baaf870..d36ef76a0b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnClassCondition.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnClassCondition.java @@ -49,7 +49,7 @@ class OnClassCondition extends FilteringSpringBootCondition { // Split the work and perform half in a background thread if more than one // processor is available. Using a single additional thread seems to offer the // best performance. More threads make things worse. - if (Runtime.getRuntime().availableProcessors() > 1) { + if (autoConfigurationClasses.length > 1 && Runtime.getRuntime().availableProcessors() > 1) { return resolveOutcomesThreaded(autoConfigurationClasses, autoConfigurationMetadata); } else {