Skip to content

Commit a0bd13c

Browse files
committed
Do not extract FactoryBean generic in case of targetType mismatch
Closes gh-32489
1 parent 46a0821 commit a0bd13c

File tree

2 files changed

+387
-437
lines changed

2 files changed

+387
-437
lines changed

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -108,7 +108,8 @@ protected boolean checkGenericTypeMatch(BeanDefinitionHolder bdHolder, Dependenc
108108
Class<?> resolvedClass = targetType.resolve();
109109
if (resolvedClass != null && FactoryBean.class.isAssignableFrom(resolvedClass)) {
110110
Class<?> typeToBeMatched = dependencyType.resolve();
111-
if (typeToBeMatched != null && !FactoryBean.class.isAssignableFrom(typeToBeMatched)) {
111+
if (typeToBeMatched != null && !FactoryBean.class.isAssignableFrom(typeToBeMatched) &&
112+
!typeToBeMatched.isAssignableFrom(resolvedClass)) {
112113
targetType = targetType.getGeneric();
113114
if (descriptor.fallbackMatchAllowed()) {
114115
// Matching the Class-based type determination for FactoryBean

0 commit comments

Comments
 (0)