Skip to content

Commit

Permalink
Consistently determine minimum number of arguments from specified index
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller authored and xcl(徐程林) committed Aug 16, 2020
1 parent a55f795 commit 01b6412
Showing 1 changed file with 3 additions and 4 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -202,7 +202,6 @@ public BeanWrapper autowireConstructor(String beanName, RootBeanDefinition mbd,
LinkedList<UnsatisfiedDependencyException> causes = null;

for (Constructor<?> candidate : candidates) {

int parameterCount = candidate.getParameterCount();

if (constructorToUse != null && argsToUse != null && argsToUse.length > parameterCount) {
Expand Down Expand Up @@ -516,8 +515,8 @@ public BeanWrapper instantiateUsingFactoryMethod(
LinkedList<UnsatisfiedDependencyException> causes = null;

for (Method candidate : candidates) {

int parameterCount = candidate.getParameterCount();

if (parameterCount >= minNrOfArgs) {
ArgumentsHolder argsHolder;

Expand Down Expand Up @@ -680,7 +679,7 @@ private int resolveConstructorArguments(String beanName, RootBeanDefinition mbd,
throw new BeanCreationException(mbd.getResourceDescription(), beanName,
"Invalid constructor argument index: " + index);
}
if (index > minNrOfArgs) {
if (index + 1 > minNrOfArgs) {
minNrOfArgs = index + 1;
}
ConstructorArgumentValues.ValueHolder valueHolder = entry.getValue();
Expand Down

0 comments on commit 01b6412

Please sign in to comment.