Updated Branches:
  refs/heads/master 9ed74a4e2 -> 03078b223

WICKET-4818 NullPointerException while reading the POST parameters

Add a check that the parameter name and values are not null.


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/03078b22
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/03078b22
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/03078b22

Branch: refs/heads/master
Commit: 03078b2231f0022c65e931f22cae6c1219ae2d06
Parents: 9ed74a4
Author: Martin Tzvetanov Grigorov <[email protected]>
Authored: Wed Oct 17 12:13:27 2012 +0200
Committer: Martin Tzvetanov Grigorov <[email protected]>
Committed: Wed Oct 17 12:13:27 2012 +0200

----------------------------------------------------------------------
 .../protocol/http/servlet/ServletWebRequest.java   |   53 ++++++++-------
 1 files changed, 28 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/03078b22/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
 
b/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
index 5555e33..9de1381 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
@@ -304,38 +304,41 @@ public class ServletWebRequest extends WebRequest
                        final String name = param.getKey();
                        final String[] values = param.getValue();
 
-                       // build a mutable list of query params that have the 
same name as the post param
-                       List<StringValue> queryValues = 
queryParams.getParameterValues(name);
-                       if (queryValues == null)
+                       if (name != null && values != null)
                        {
-                               queryValues = Collections.emptyList();
-                       }
-                       else
-                       {
-                               queryValues = new 
ArrayList<StringValue>(queryValues);
-                       }
-
-                       // the list that will contain accepted post param values
-                       List<StringValue> postValues = new 
ArrayList<StringValue>();
-
-                       for (String value : values)
-                       {
-                               StringValue val = StringValue.valueOf(value);
-                               if (queryValues.contains(val))
+                               // build a mutable list of query params that 
have the same name as the post param
+                               List<StringValue> queryValues = 
queryParams.getParameterValues(name);
+                               if (queryValues == null)
                                {
-                                       // if a query param with this value 
exists remove it and continue
-                                       queryValues.remove(val);
+                                       queryValues = Collections.emptyList();
                                }
                                else
                                {
-                                       // there is no query param with this 
value, assume post
-                                       postValues.add(val);
+                                       queryValues = new 
ArrayList<StringValue>(queryValues);
                                }
-                       }
 
-                       if (!postValues.isEmpty())
-                       {
-                               postParameters.put(name, postValues);
+                               // the list that will contain accepted post 
param values
+                               List<StringValue> postValues = new 
ArrayList<StringValue>();
+
+                               for (String value : values)
+                               {
+                                       StringValue val = 
StringValue.valueOf(value);
+                                       if (queryValues.contains(val))
+                                       {
+                                               // if a query param with this 
value exists remove it and continue
+                                               queryValues.remove(val);
+                                       }
+                                       else
+                                       {
+                                               // there is no query param with 
this value, assume post
+                                               postValues.add(val);
+                                       }
+                               }
+
+                               if (!postValues.isEmpty())
+                               {
+                                       postParameters.put(name, postValues);
+                               }
                        }
                }
                return postParameters;

Reply via email to