preserve custom pre-bound RequestAttributes implementations (for Grails)
This commit is contained in:
@@ -603,8 +603,11 @@ public abstract class FrameworkServlet extends HttpServletBean
|
||||
|
||||
// Expose current RequestAttributes to current thread.
|
||||
RequestAttributes previousRequestAttributes = RequestContextHolder.getRequestAttributes();
|
||||
ServletRequestAttributes requestAttributes = new ServletRequestAttributes(request);
|
||||
RequestContextHolder.setRequestAttributes(requestAttributes, this.threadContextInheritable);
|
||||
ServletRequestAttributes requestAttributes = null;
|
||||
if (previousRequestAttributes == null || previousRequestAttributes.getClass().equals(ServletRequestAttributes.class)) {
|
||||
requestAttributes = new ServletRequestAttributes(request);
|
||||
RequestContextHolder.setRequestAttributes(requestAttributes, this.threadContextInheritable);
|
||||
}
|
||||
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Bound request context to thread: " + request);
|
||||
@@ -627,12 +630,12 @@ public abstract class FrameworkServlet extends HttpServletBean
|
||||
}
|
||||
|
||||
finally {
|
||||
// Reset thread-bound context.
|
||||
RequestContextHolder.setRequestAttributes(previousRequestAttributes, this.threadContextInheritable);
|
||||
// Clear request attributes and reset thread-bound context.
|
||||
LocaleContextHolder.setLocaleContext(previousLocaleContext, this.threadContextInheritable);
|
||||
|
||||
// Clear request attributes.
|
||||
requestAttributes.requestCompleted();
|
||||
if (requestAttributes != null) {
|
||||
RequestContextHolder.setRequestAttributes(previousRequestAttributes, this.threadContextInheritable);
|
||||
requestAttributes.requestCompleted();
|
||||
}
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Cleared thread-bound request context: " + request);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user