-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Ben Jordan opened SPR-10937 and commented
Before I get into this, I'm willing to accept that what I'm doing is wrong (very old code). If so feel free to close this.
I have a OncePerRequestFilter that is invoked in the Spring Security chain after the FORM_LOGIN_FILTER filter. Inside this filter, the code decides whether some conditions are true and if so it redirects the user to a new page:
public void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
if (someEvent) {
new RedirectView(someUrl, true).render(model, request, response);
return; // Stop the filter chain
}
chain.doFilter(request, response); // Keep going
}
In RedirectView's renderMergedOutputModel method, a null pointer exception (silently for some reason) occurs because the following line returns null:
FlashMapManager flashMapManager = RequestContextUtils.getFlashMapManager(request);
flashMapManager.saveOutputFlashMap(flashMap, request, response); // Null Pointer
Having thrown some breakpoints around it seems to be because the DispatcherServlet hasn't added the FlashMapManager into the request as the filter was invoked before the DispatcherServlet.
I can get around this by overriding renderMergedOutputModel and taking out the stuff about flash attributes as I do not need them.
Again, happy to be told I'm "doing it wrong".
Affects: 3.2.4
Referenced from: commits 4ac6801, 70907fd
1 votes, 4 watchers