|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2012 the original author or authors. |
|
|
|
* Copyright 2002-2014 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -64,17 +64,19 @@ public class RequestContextListener implements ServletRequestListener { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void requestDestroyed(ServletRequestEvent requestEvent) { |
|
|
|
public void requestDestroyed(ServletRequestEvent requestEvent) { |
|
|
|
ServletRequestAttributes attributes = |
|
|
|
ServletRequestAttributes attributes = null; |
|
|
|
(ServletRequestAttributes) requestEvent.getServletRequest().getAttribute(REQUEST_ATTRIBUTES_ATTRIBUTE); |
|
|
|
Object reqAttr = requestEvent.getServletRequest().getAttribute(REQUEST_ATTRIBUTES_ATTRIBUTE); |
|
|
|
ServletRequestAttributes threadAttributes = |
|
|
|
if (reqAttr instanceof ServletRequestAttributes) { |
|
|
|
(ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); |
|
|
|
attributes = (ServletRequestAttributes) reqAttr; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
RequestAttributes threadAttributes = RequestContextHolder.getRequestAttributes(); |
|
|
|
if (threadAttributes != null) { |
|
|
|
if (threadAttributes != null) { |
|
|
|
// We're assumably within the original request thread...
|
|
|
|
// We're assumably within the original request thread...
|
|
|
|
if (attributes == null) { |
|
|
|
|
|
|
|
attributes = threadAttributes; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
LocaleContextHolder.resetLocaleContext(); |
|
|
|
LocaleContextHolder.resetLocaleContext(); |
|
|
|
RequestContextHolder.resetRequestAttributes(); |
|
|
|
RequestContextHolder.resetRequestAttributes(); |
|
|
|
|
|
|
|
if (attributes == null && threadAttributes instanceof ServletRequestAttributes) { |
|
|
|
|
|
|
|
attributes = (ServletRequestAttributes) threadAttributes; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (attributes != null) { |
|
|
|
if (attributes != null) { |
|
|
|
attributes.requestCompleted(); |
|
|
|
attributes.requestCompleted(); |
|
|
|
|