Treat Kotlin nullable as non-required
Where `isOptional` is used, also check for `isNullable` i.e. values are not considered required if they are Kotlin nullables: - spring-messaging: named value method arguments - spring-web: named value method arguments - spring-webmvc: request parts This means that Kotlin client code no longer has to explicity specify "required=false" for Kotlin nullables -- this information is inferred automatically by the framework. Issue: SPR-14165
This commit is contained in:
committed by
Sebastien Deleuze
parent
735e288d46
commit
fada91e538
@@ -98,7 +98,7 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
|
||||
if (namedValueInfo.defaultValue != null) {
|
||||
arg = resolveStringValue(namedValueInfo.defaultValue);
|
||||
}
|
||||
else if (namedValueInfo.required && !nestedParameter.isOptional()) {
|
||||
else if (namedValueInfo.required && !nestedParameter.isOptional() && !nestedParameter.isNullable()) {
|
||||
handleMissingValue(namedValueInfo.name, nestedParameter, message);
|
||||
}
|
||||
arg = handleNullValue(namedValueInfo.name, arg, nestedParameter.getNestedParameterType());
|
||||
|
||||
Reference in New Issue
Block a user