Skip to content

Commit f9aae8d

Browse files
committed
Consistently determine minimum number of arguments from specified index
Closes gh-25130
1 parent 4f65ba4 commit f9aae8d

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -202,7 +202,6 @@ public BeanWrapper autowireConstructor(String beanName, RootBeanDefinition mbd,
202202
LinkedList<UnsatisfiedDependencyException> causes = null;
203203

204204
for (Constructor<?> candidate : candidates) {
205-
206205
int parameterCount = candidate.getParameterCount();
207206

208207
if (constructorToUse != null && argsToUse != null && argsToUse.length > parameterCount) {
@@ -515,8 +514,8 @@ public BeanWrapper instantiateUsingFactoryMethod(
515514
LinkedList<UnsatisfiedDependencyException> causes = null;
516515

517516
for (Method candidate : candidates) {
518-
519517
int parameterCount = candidate.getParameterCount();
518+
520519
if (parameterCount >= minNrOfArgs) {
521520
ArgumentsHolder argsHolder;
522521

@@ -679,7 +678,7 @@ private int resolveConstructorArguments(String beanName, RootBeanDefinition mbd,
679678
throw new BeanCreationException(mbd.getResourceDescription(), beanName,
680679
"Invalid constructor argument index: " + index);
681680
}
682-
if (index > minNrOfArgs) {
681+
if (index + 1 > minNrOfArgs) {
683682
minNrOfArgs = index + 1;
684683
}
685684
ConstructorArgumentValues.ValueHolder valueHolder = entry.getValue();

0 commit comments

Comments
 (0)