From 73bf5f3d207b2063bd9f63196875187c2534f2b7 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 13 Jan 2026 11:02:32 +0000 Subject: [PATCH] Avoid querying BeanFactory for beans of type ResolvableType.NONE ResolvableType.NONE represents a type that does not exist and, therefore could not be loaded. A bean of such a type cannot be present in the BeanFactory so querying it for beans of that type is pointless. This commit updates OnBeanCondition to return immediately rather than querying the BeanFactory by type for beans that we know cannot be present. Fixes gh-48836 --- .../boot/autoconfigure/condition/OnBeanCondition.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java index 767e871811c..e6362b63e28 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java @@ -320,6 +320,9 @@ class OnBeanCondition extends FilteringSpringBootCondition implements Configurat private Map collectBeanDefinitionsForType(ListableBeanFactory beanFactory, boolean considerHierarchy, BeanType type, Set parameterizedContainers, Map result) { + if (ResolvableType.NONE.equals(type.resolvableType())) { + return result; + } result = putAll(result, beanFactory.getBeanNamesForType(type.resolvableType(), true, false), beanFactory); for (BeanType parameterizedContainer : parameterizedContainers) { Class resolved = parameterizedContainer.resolvableType().resolve();