Proper resolution of Optional.empty() for header arguments

Issue: SPR-15151
(cherry picked from commit e9db4d6)
This commit is contained in:
Juergen Hoeller
2017-01-17 10:46:37 +01:00
parent f79baec5ff
commit caebe72083
2 changed files with 36 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 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.
@@ -53,6 +53,7 @@ import org.springframework.util.ClassUtils;
* argument value if it doesn't match the method parameter type.
*
* @author Rossen Stoyanchev
* @author Juergen Hoeller
* @since 4.0
*/
public abstract class AbstractNamedValueMethodArgumentResolver implements HandlerMethodArgumentResolver {
@@ -107,7 +108,7 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
arg = resolveStringValue(namedValueInfo.defaultValue);
}
if (!ClassUtils.isAssignableValue(parameter.getParameterType(), arg)) {
if (parameter != nestedParameter || !ClassUtils.isAssignableValue(parameter.getParameterType(), arg)) {
arg = this.conversionService.convert(arg, TypeDescriptor.forObject(arg), new TypeDescriptor(parameter));
}