Unwrap Optional for @RequestParam reverse resolution
Closes gh-22656
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -20,6 +20,7 @@ import java.beans.PropertyEditor;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.Part;
|
||||
|
||||
@@ -217,6 +218,11 @@ public class RequestParamMethodArgumentResolver extends AbstractNamedValueMethod
|
||||
parameter.getParameterName() : requestParam.name());
|
||||
Assert.state(name != null, "Unresolvable parameter name");
|
||||
|
||||
parameter = parameter.nestedIfOptional();
|
||||
if (value instanceof Optional) {
|
||||
value = ((Optional<?>) value).orElse(null);
|
||||
}
|
||||
|
||||
if (value == null) {
|
||||
if (requestParam != null &&
|
||||
(!requestParam.required() || !requestParam.defaultValue().equals(ValueConstants.DEFAULT_NONE))) {
|
||||
|
||||
Reference in New Issue
Block a user