Skip to content

Commit

Permalink
Prepare method overrides when bean class gets resolved
Browse files Browse the repository at this point in the history
See gh-31826
See gh-31828

(cherry picked from commit cd64e66)
  • Loading branch information
jhoeller authored and sbrannen committed Dec 13, 2023
1 parent db52c77 commit 76bc9cf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -493,15 +493,13 @@ protected Object createBean(String beanName, RootBeanDefinition mbd, @Nullable O
if (resolvedClass != null && !mbd.hasBeanClass() && mbd.getBeanClassName() != null) {
mbdToUse = new RootBeanDefinition(mbd);
mbdToUse.setBeanClass(resolvedClass);
}

// Prepare method overrides.
try {
mbdToUse.prepareMethodOverrides();
}
catch (BeanDefinitionValidationException ex) {
throw new BeanDefinitionStoreException(mbdToUse.getResourceDescription(),
beanName, "Validation of method overrides failed", ex);
try {
mbdToUse.prepareMethodOverrides();
}
catch (BeanDefinitionValidationException ex) {
throw new BeanDefinitionStoreException(mbdToUse.getResourceDescription(),
beanName, "Validation of method overrides failed", ex);
}
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1497,14 +1497,22 @@ protected Class<?> resolveBeanClass(RootBeanDefinition mbd, String beanName, Cla
if (mbd.hasBeanClass()) {
return mbd.getBeanClass();
}
return doResolveBeanClass(mbd, typesToMatch);
Class<?> beanClass = doResolveBeanClass(mbd, typesToMatch);
if (mbd.hasBeanClass()) {
mbd.prepareMethodOverrides();
}
return beanClass;
}
catch (ClassNotFoundException ex) {
throw new CannotLoadBeanClassException(mbd.getResourceDescription(), beanName, mbd.getBeanClassName(), ex);
}
catch (LinkageError err) {
throw new CannotLoadBeanClassException(mbd.getResourceDescription(), beanName, mbd.getBeanClassName(), err);
}
catch (BeanDefinitionValidationException ex) {
throw new BeanDefinitionStoreException(mbd.getResourceDescription(),
beanName, "Validation of method overrides failed", ex);
}
}

@Nullable
Expand Down

0 comments on commit 76bc9cf

Please sign in to comment.