Fixed regression in SpEL's constructor resolution

Issue: SPR-11348
This commit is contained in:
Juergen Hoeller
2014-01-23 20:52:21 +01:00
parent 8faf01f56d
commit 86fc2dd556
2 changed files with 41 additions and 11 deletions

View File

@@ -68,6 +68,7 @@ public class ReflectiveConstructorResolver implements ConstructorResolver {
});
Constructor<?> closeMatch = null;
Constructor<?> matchRequiringConversion = null;
for (Constructor<?> ctor : ctors) {
Class<?>[] paramTypes = ctor.getParameterTypes();
@@ -93,13 +94,24 @@ public class ReflectiveConstructorResolver implements ConstructorResolver {
if (matchInfo.isExactMatch()) {
return new ReflectiveConstructorExecutor(ctor);
}
else if (matchInfo.isCloseMatch() || matchInfo.isMatchRequiringConversion()) {
else if (matchInfo.isCloseMatch()) {
closeMatch = ctor;
}
else if (matchInfo.isMatchRequiringConversion()) {
matchRequiringConversion = ctor;
}
}
}
return (closeMatch != null ? new ReflectiveConstructorExecutor(closeMatch) : null);
if (closeMatch != null) {
return new ReflectiveConstructorExecutor(closeMatch);
}
else if (matchRequiringConversion != null) {
return new ReflectiveConstructorExecutor(matchRequiringConversion);
}
else {
return null;
}
}
catch (EvaluationException ex) {
throw new AccessException("Failed to resolve constructor", ex);