mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-25 05:22:16 +00:00
Prevent NullPointerException when not loaded from application context
This commit is contained in:
parent
d847772c81
commit
27de814d54
@ -100,6 +100,10 @@ public class HttpSessionContextIntegrationFilter implements InitializingBean, Fi
|
|||||||
*/
|
*/
|
||||||
private boolean forceEagerSessionCreation = false;
|
private boolean forceEagerSessionCreation = false;
|
||||||
|
|
||||||
|
public HttpSessionContextIntegrationFilter() throws ServletException {
|
||||||
|
this.contextObject = generateNewContext();
|
||||||
|
}
|
||||||
|
|
||||||
//~ Methods ========================================================================================================
|
//~ Methods ========================================================================================================
|
||||||
|
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
@ -113,8 +117,6 @@ public class HttpSessionContextIntegrationFilter implements InitializingBean, Fi
|
|||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"If using forceEagerSessionCreation, you must set allowSessionCreation to also be true");
|
"If using forceEagerSessionCreation, you must set allowSessionCreation to also be true");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.contextObject = generateNewContext();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -190,7 +190,8 @@ public class HttpSessionContextIntegrationFilterTests extends TestCase {
|
|||||||
// Prepare filter
|
// Prepare filter
|
||||||
HttpSessionContextIntegrationFilter filter = new HttpSessionContextIntegrationFilter();
|
HttpSessionContextIntegrationFilter filter = new HttpSessionContextIntegrationFilter();
|
||||||
filter.setContext(SecurityContextImpl.class);
|
filter.setContext(SecurityContextImpl.class);
|
||||||
filter.afterPropertiesSet();
|
// don't call afterPropertiesSet to test case when not instantiated by Spring
|
||||||
|
//filter.afterPropertiesSet();
|
||||||
|
|
||||||
// Execute filter
|
// Execute filter
|
||||||
executeFilterInContainerSimulator(new MockFilterConfig(), filter, request, response, chain);
|
executeFilterInContainerSimulator(new MockFilterConfig(), filter, request, response, chain);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user