From a6ff95a69c765b029ce0dca960345cc4360f5a58 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 4 Aug 2023 00:56:01 +0200 Subject: [PATCH] Restore restrictive getTypeForFactoryBeanFromAttributes check See gh-29799 See gh-30987 --- .../beans/factory/support/FactoryBeanRegistrySupport.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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()); } /**