BATCH-1742: cover a corner case of overloaded methods in HippyMethodInvoker

This commit is contained in:
Dave Syer
2011-05-04 09:19:39 +01:00
parent 2bfba444dc
commit 5b81bf0361
2 changed files with 116 additions and 86 deletions

View File

@@ -51,6 +51,7 @@ public class HippyMethodInvoker extends MethodInvoker {
Class<?>[] paramTypes = candidate.getParameterTypes();
Object[] candidateArguments = new Object[paramTypes.length];
int assignedParameterCount = 0;
boolean assigned = paramTypes.length==0;
for (int j = 0; j < arguments.length; j++) {
for (int k = 0; k < paramTypes.length; k++) {
// Pick the first assignable of the right type that
@@ -58,11 +59,12 @@ public class HippyMethodInvoker extends MethodInvoker {
if (ClassUtils.isAssignableValue(paramTypes[k], arguments[j]) && candidateArguments[k] == null) {
candidateArguments[k] = arguments[j];
assignedParameterCount++;
assigned = true;
break;
}
}
}
if (paramTypes.length <= argCount) {
if (assigned && paramTypes.length <= argCount) {
int typeDiffWeight = getTypeDifferenceWeight(paramTypes, candidateArguments);
if (typeDiffWeight < minTypeDiffWeight) {
minTypeDiffWeight = typeDiffWeight;