Expose FactoryBean attribute exception as BeanDefinitionStoreException
Closes gh-33117
This commit is contained in:
@@ -843,10 +843,17 @@ 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);
|
||||
if (result != ResolvableType.NONE) {
|
||||
return result;
|
||||
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
|
||||
|
||||
@@ -1716,9 +1716,14 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
* @see #getBean(String)
|
||||
*/
|
||||
protected ResolvableType getTypeForFactoryBean(String beanName, RootBeanDefinition mbd, boolean allowInit) {
|
||||
ResolvableType result = getTypeForFactoryBeanFromAttributes(mbd);
|
||||
if (result != ResolvableType.NONE) {
|
||||
return result;
|
||||
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()) {
|
||||
|
||||
Reference in New Issue
Block a user