diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/FactoryBeanRegistrySupport.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/FactoryBeanRegistrySupport.java index 72644917ea..bd19a2f4fc 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/FactoryBeanRegistrySupport.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/FactoryBeanRegistrySupport.java @@ -73,13 +73,17 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg */ ResolvableType getTypeForFactoryBeanFromAttributes(AttributeAccessor attributes) { Object attribute = attributes.getAttribute(FactoryBean.OBJECT_TYPE_ATTRIBUTE); + if (attribute == null) { + return ResolvableType.NONE; + } if (attribute instanceof ResolvableType resolvableType) { return resolvableType; } if (attribute instanceof Class clazz) { return ResolvableType.forClass(clazz); } - return ResolvableType.NONE; + throw new IllegalArgumentException("Invalid value type for attribute '" + + FactoryBean.OBJECT_TYPE_ATTRIBUTE + "': " + attribute.getClass().getName()); } /**