for (Map.Entry entry : cargs.getIndexedArgumentValues.entrySet) {
int index = entry.getKey;
if (index < 0) {
throw new BeanCreationException(mbd.getResourceDescription, beanName,
"Invalid constructor argument index: " + index);
}
if (index > minNrOfArgs) {
minNrOfArgs = index + 1;
}
// ....
}
// ....
return minNrOfArgs;
}I assume that method resolveConstructorArguments is to resolve contructor arguments in the XML file and return the minimum number of parameters required by contructor. But if the first parameter is autowired , the second parameter is config by XML file,the method will not work well.
Example:
public class FactoryObject {
public DmzService getDmz(String name, int age, Date birthDay, OrderService orderService) {
public DmzService getDmz(OrderService orderService,String name) {
return new DmzService(orderService,name);
}
}
The resolveConstructorArguments method will return 1,but correct answer is 2.
I think the problem arises because of this judgment:
if (index > minNrOfArgs) {
minNrOfArgs = index + 1;
}It might be better to change it to look like this.
if (index + 1 > minNrOfArgs) {
minNrOfArgs = index + 1;
}s