struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject svn commit: r781798 - in /struts/struts2/trunk/core/src: main/java/org/apache/struts2/util/TokenHelper.java test/java/org/apache/struts2/util/TokenHelperTest.java
Date Thu, 04 Jun 2009 17:08:35 GMT
Author: wesw
Date: Thu Jun  4 17:08:35 2009
New Revision: 781798

URL: http://svn.apache.org/viewvc?rev=781798&view=rev
Log:
Fixing NPE in token processing WW-3150, thanks James Peltzer

Modified:
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/TokenHelper.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/TokenHelperTest.java

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/TokenHelper.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/TokenHelper.java?rev=781798&r1=781797&r2=781798&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/TokenHelper.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/TokenHelper.java Thu Jun
 4 17:08:35 2009
@@ -97,6 +97,9 @@
      * @return the token String or null, if the token could not be found
      */
     public static String getToken(String tokenName) {
+        if (tokenName == null ) {
+            return null;
+        }
         Map params = ActionContext.getContext().getParameters();
         String[] tokens = (String[]) params.get(tokenName);
         String token;

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/TokenHelperTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/TokenHelperTest.java?rev=781798&r1=781797&r2=781798&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/TokenHelperTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/TokenHelperTest.java Thu
Jun  4 17:08:35 2009
@@ -58,6 +58,11 @@
         assertTrue(TokenHelper.validToken());
     }
 
+    public void testGetTokenDoesNotNpe() {
+        String token = TokenHelper.getToken(null);
+        assertTrue(token == null);
+    }
+
     protected void setUp() throws Exception {
         session = new HashMap();
         Map params = new HashMap();



Mime
View raw message