Author: wesw
Date: Thu Jun  4 19:38:07 2009
New Revision: 781838

URL: http://svn.apache.org/viewvc?rev=781838&view=rev
Log:
More NPE possible in TokenSessionStoreInterceptor, updated unit tests again 
WW-3150

Modified:
    
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptor.java
    
struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenInterceptorTest.java
    
struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptorTest.java

Modified: 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptor.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptor.java?rev=781838&r1=781837&r2=781838&view=diff
==============================================================================
--- 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptor.java
 (original)
+++ 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptor.java
 Thu Jun  4 19:38:07 2009
@@ -116,11 +116,11 @@
         String tokenName = TokenHelper.getTokenName();
         String token = TokenHelper.getToken(tokenName);
 
-        Map params = ac.getParameters();
-        params.remove(tokenName);
-        params.remove(TokenHelper.TOKEN_NAME_FIELD);
-
         if ((tokenName != null) && (token != null)) {
+            Map params = ac.getParameters();
+            params.remove(tokenName);
+            params.remove(TokenHelper.TOKEN_NAME_FIELD);
+
             ActionInvocation savedInvocation = 
InvocationSessionStore.loadInvocation(tokenName, token);
 
             if (savedInvocation != null) {

Modified: 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenInterceptorTest.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenInterceptorTest.java?rev=781838&r1=781837&r2=781838&view=diff
==============================================================================
--- 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenInterceptorTest.java
 (original)
+++ 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenInterceptorTest.java
 Thu Jun  4 19:38:07 2009
@@ -23,6 +23,7 @@
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.TreeMap;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
@@ -110,9 +111,9 @@
     protected void setUp() throws Exception {
         loadConfigurationProviders(new TestConfigurationProvider());
 
-        session = new HashMap();
-        params = new HashMap();
-        extraContext = new HashMap();
+        session = new TreeMap();
+        params = new TreeMap();
+        extraContext = new TreeMap();
         extraContext.put(ActionContext.SESSION, session);
         extraContext.put(ActionContext.PARAMETERS, params);
 

Modified: 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptorTest.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptorTest.java?rev=781838&r1=781837&r2=781838&view=diff
==============================================================================
--- 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptorTest.java
 (original)
+++ 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptorTest.java
 Thu Jun  4 19:38:07 2009
@@ -44,6 +44,12 @@
         assertEquals(Action.SUCCESS, proxy2.execute());
     }
 
+    public void testNullTokenName() throws Exception {
+        ActionProxy proxy = buildProxy(getActionName());
+        setToken((String)null);
+        proxy.execute();
+    }
+
     protected String getActionName() {
         return TestConfigurationProvider.TOKEN_SESSION_ACTION_NAME;
     }


Reply via email to