2929import java .util .List ;
3030import java .util .Optional ;
3131import java .util .function .Function ;
32+ import java .util .function .Predicate ;
3233import java .util .stream .Collectors ;
3334
3435import org .jooby .MediaType ;
3738import org .jooby .spi .NativeUpload ;
3839import org .jooby .spi .NativeWebSocket ;
3940
41+ import com .google .common .base .Strings ;
4042import com .google .common .collect .ArrayListMultimap ;
4143import com .google .common .collect .ImmutableList ;
4244import com .google .common .collect .Multimap ;
@@ -232,8 +234,10 @@ private Multimap<String, String> decodeParams() throws IOException {
232234 params = ArrayListMultimap .create ();
233235 files = ArrayListMultimap .create ();
234236
237+ Predicate <String > notEmpty = s -> !Strings .isNullOrEmpty (s );
235238 query .parameters ()
236- .forEach ((name , values ) -> values .forEach (value -> params .put (name , value )));
239+ .forEach ((name , values ) -> values .stream ().filter (notEmpty )
240+ .forEach (value -> params .put (name , value )));
237241
238242 HttpMethod method = req .method ();
239243 boolean hasBody = method .equals (HttpMethod .POST ) || method .equals (HttpMethod .PUT )
@@ -258,16 +262,19 @@ private Multimap<String, String> decodeParams() throws IOException {
258262 while (hasNext .apply (decoder )) {
259263 HttpData field = (HttpData ) decoder .next ();
260264 try {
261- String name = field .getName ();
262- switch (field .getHttpDataType ()) {
263- case FileUpload :
264- files .put (name , new NettyUpload ((FileUpload ) field , tmpdir ));
265- // excludes upload from param names.
266- break ;
267- default :
268- params .put (name , field .getString ());
269- break ;
270- }
265+ String name = field .getName ();
266+ switch (field .getHttpDataType ()) {
267+ case FileUpload :
268+ files .put (name , new NettyUpload ((FileUpload ) field , tmpdir ));
269+ // excludes upload from param names.
270+ break ;
271+ default :
272+ String value = field .getString ();
273+ if (notEmpty .test (value )) {
274+ params .put (name , value );
275+ }
276+ break ;
277+ }
271278 } finally {
272279 field .release ();
273280 }
0 commit comments