You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ArgumentConvertingMethodInvoker - permanently mutates param values while testing for match via param value conversion. May affect later match attempts in the method? [SPR-1656] #6353
The 2nd pass of org/springframework/beans/support/ArgumentConvertingMethodInvoker.findMatchingMethod() mutates the param values as it tests for matches.
Unless conversion is automatcally reversible ths looks like it could prevent some matches in certain cases (ie more than one instance of the method name and
they have the same number of arguments and the first test mutates a param in a way that is not convertible to the 2nd).
Should probably make a shallow copy of of the orginal arguments array on each match pass instead.
This base solely on code inspection! Here's the loop in question with annotation:
// Second pass: look for method where arguments can be converted to parameter types.
for (int i = 0; i < candidates.length; i++) {
if (candidates[i].getName().equals(getTargetMethod())) {
// Check if the inspected method has the correct number of parameters.
Class[] paramTypes = candidates[i].getParameterTypes();
if (paramTypes.length == argCount) {
Object[] argumentsToUse = arguments; /* SHOULD BE A COPY ? */
int numberOfCorrectArguments = 0;
for (int j = 0; j < argCount; j++) {
// Verify that the supplied argument is assignable to the method parameter.
try {
argumentsToUse[j] = this.beanWrapper.doTypeConversionIfNecessary(arguments[j], paramTypes[j]); /* POTENTIAL MUTATION of PARAM VALUE */
numberOfCorrectArguments++;
}
catch (TypeMismatchException ex) {
// Ignore -> simply doesn't match.
}
}
if (numberOfCorrectArguments == argumentsToUse.length) {
setArguments(argumentsToUse);
return candidates[i];
}
}
}
}