Prevent NullPointerException when not loaded from application context

This commit is contained in:
Carlos Sanchez 2006-07-05 15:59:17 +00:00
parent d847772c81
commit 27de814d54
2 changed files with 6 additions and 3 deletions

View File

@ -100,6 +100,10 @@ public class HttpSessionContextIntegrationFilter implements InitializingBean, Fi
*/
private boolean forceEagerSessionCreation = false;
public HttpSessionContextIntegrationFilter() throws ServletException {
this.contextObject = generateNewContext();
}
//~ Methods ========================================================================================================
public void afterPropertiesSet() throws Exception {
@ -113,8 +117,6 @@ public class HttpSessionContextIntegrationFilter implements InitializingBean, Fi
throw new IllegalArgumentException(
"If using forceEagerSessionCreation, you must set allowSessionCreation to also be true");
}
this.contextObject = generateNewContext();
}
/**

View File

@ -190,7 +190,8 @@ public class HttpSessionContextIntegrationFilterTests extends TestCase {
// Prepare filter
HttpSessionContextIntegrationFilter filter = new HttpSessionContextIntegrationFilter();
filter.setContext(SecurityContextImpl.class);
filter.afterPropertiesSet();
// don't call afterPropertiesSet to test case when not instantiated by Spring
//filter.afterPropertiesSet();
// Execute filter
executeFilterInContainerSimulator(new MockFilterConfig(), filter, request, response, chain);