Allow for null query parameter values in ServerRequest

With this commit, ServerRequest allows for `null` values in query
parameters, treating them as empty values instead.

Issue: SPR-15609
This commit is contained in:
Arjen Poutsma
2017-06-01 18:00:54 +02:00
parent b93579a43e
commit 8ea54270e1
2 changed files with 76 additions and 65 deletions

View File

@@ -129,7 +129,16 @@ public interface ServerRequest {
*/
default Optional<String> queryParam(String name) {
List<String> queryParams = this.queryParams(name);
return (!queryParams.isEmpty() ? Optional.of(queryParams.get(0)) : Optional.empty());
if (queryParams.isEmpty()) {
return Optional.empty();
}
else {
String value = queryParams.get(0);
if (value == null) {
value = "";
}
return Optional.of(value);
}
}
/**