Skip to content

Commit

Permalink
Expose FactoryBean attribute exception as BeanDefinitionStoreException
Browse files Browse the repository at this point in the history
Closes gh-33117
  • Loading branch information
jhoeller committed Jun 28, 2024
1 parent c74666a commit 61894af
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -843,10 +843,17 @@ protected Class<?> getTypeForFactoryMethod(String beanName, RootBeanDefinition m
*/
@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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1716,9 +1716,14 @@ protected boolean isFactoryBean(String beanName, RootBeanDefinition mbd) {
* @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()) {
Expand Down

0 comments on commit 61894af

Please sign in to comment.