More NPE possible in TokenSessionStoreInterceptor, updated unit tests again WW-3150

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@781838 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Wesley Wannemacher
2009-06-04 19:38:07 +00:00
parent ee1b9aac9b
commit 1b19830293
3 changed files with 14 additions and 7 deletions
@@ -116,11 +116,11 @@ public class TokenSessionStoreInterceptor extends TokenInterceptor {
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) {
@@ -23,6 +23,7 @@ package org.apache.struts2.interceptor;
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 @@ public class TokenInterceptorTest extends StrutsTestCase {
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);
@@ -44,6 +44,12 @@ public class TokenSessionStoreInterceptorTest extends TokenInterceptorTest {
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;
}