Expose FactoryBean attribute exception as BeanDefinitionStoreException

Closes gh-33117
This commit is contained in:
Juergen Hoeller 2024-06-28 17:55:45 +02:00
parent c74666a883
commit 61894af0bd
2 changed files with 18 additions and 6 deletions

View File

@ -843,11 +843,18 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
*/
@Override
protected ResolvableType getTypeForFactoryBean(String beanName, RootBeanDefinition mbd, boolean allowInit) {
ResolvableType result;
// Check if the bean definition itself has defined the type with an attribute
ResolvableType result = getTypeForFactoryBeanFromAttributes(mbd);
try {
result = getTypeForFactoryBeanFromAttributes(mbd);
if (result != ResolvableType.NONE) {
return result;
}
}
catch (IllegalArgumentException ex) {
throw new BeanDefinitionStoreException(mbd.getResourceDescription(), beanName, ex.getMessage());
}
// For instance supplied beans, try the target type and bean class immediately
if (mbd.getInstanceSupplier() != null) {

View File

@ -1716,10 +1716,15 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
* @see #getBean(String)
*/
protected ResolvableType getTypeForFactoryBean(String beanName, RootBeanDefinition mbd, boolean allowInit) {
try {
ResolvableType result = getTypeForFactoryBeanFromAttributes(mbd);
if (result != ResolvableType.NONE) {
return result;
}
}
catch (IllegalArgumentException ex) {
throw new BeanDefinitionStoreException(mbd.getResourceDescription(), beanName, ex.getMessage());
}
if (allowInit && mbd.isSingleton()) {
try {