Skip to content

Commit c2a5fcd

Browse files
committed
Fallback to empty collection/map only if actually no target bean found
Issue: SPR-15338
1 parent 14d0fee commit c2a5fcd

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import org.springframework.beans.factory.BeanDefinitionStoreException;
4646
import org.springframework.beans.factory.InjectionPoint;
4747
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
48+
import org.springframework.beans.factory.NoUniqueBeanDefinitionException;
4849
import org.springframework.beans.factory.UnsatisfiedDependencyException;
4950
import org.springframework.beans.factory.config.ConstructorArgumentValues;
5051
import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder;
@@ -823,6 +824,9 @@ protected Object resolveAutowiredArgument(MethodParameter param, String beanName
823824
return this.beanFactory.resolveDependency(
824825
new DependencyDescriptor(param, true), beanName, autowiredBeanNames, typeConverter);
825826
}
827+
catch (NoUniqueBeanDefinitionException ex) {
828+
throw ex;
829+
}
826830
catch (NoSuchBeanDefinitionException ex) {
827831
if (fallback) {
828832
// Single constructor or factory method -> let's return an empty array/collection

0 commit comments

Comments
 (0)