Skip to content

Commit 52e1f30

Browse files
committed
Merge branch '6.1.x'
2 parents e3048bc + 2861e57 commit 52e1f30

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java

+14-4
Original file line numberDiff line numberDiff line change
@@ -814,10 +814,20 @@ protected Class<?> getTypeForFactoryMethod(String beanName, RootBeanDefinition m
814814

815815
// Common return type found: all factory methods return same type. For a non-parameterized
816816
// unique candidate, cache the full type declaration context of the target factory method.
817-
cachedReturnType = (uniqueCandidate != null ?
818-
ResolvableType.forMethodReturnType(uniqueCandidate) : ResolvableType.forClass(commonType));
819-
mbd.factoryMethodReturnType = cachedReturnType;
820-
return cachedReturnType.resolve();
817+
try {
818+
cachedReturnType = (uniqueCandidate != null ?
819+
ResolvableType.forMethodReturnType(uniqueCandidate) : ResolvableType.forClass(commonType));
820+
mbd.factoryMethodReturnType = cachedReturnType;
821+
return cachedReturnType.resolve();
822+
}
823+
catch (LinkageError err) {
824+
// E.g. a NoClassDefFoundError for a generic method return type
825+
if (logger.isDebugEnabled()) {
826+
logger.debug("Failed to resolve type for factory method of bean '" + beanName + "': " +
827+
(uniqueCandidate != null ? uniqueCandidate : commonType), err);
828+
}
829+
return null;
830+
}
821831
}
822832

823833
/**

0 commit comments

Comments
 (0)