FrameworkPortlet exposes local PortletRequestAttributes in case of pre-bound ServletRequestAttributes as well
Issue: SPR-11295
This commit is contained in:
parent
938a2846c8
commit
2d892da641
|
@ -44,6 +44,7 @@ import org.springframework.context.i18n.SimpleLocaleContext;
|
||||||
import org.springframework.core.env.ConfigurableEnvironment;
|
import org.springframework.core.env.ConfigurableEnvironment;
|
||||||
import org.springframework.web.context.request.RequestAttributes;
|
import org.springframework.web.context.request.RequestAttributes;
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
import org.springframework.web.portlet.context.ConfigurablePortletApplicationContext;
|
import org.springframework.web.portlet.context.ConfigurablePortletApplicationContext;
|
||||||
import org.springframework.web.portlet.context.PortletApplicationContextUtils;
|
import org.springframework.web.portlet.context.PortletApplicationContextUtils;
|
||||||
import org.springframework.web.portlet.context.PortletRequestAttributes;
|
import org.springframework.web.portlet.context.PortletRequestAttributes;
|
||||||
|
@ -516,7 +517,8 @@ public abstract class FrameworkPortlet extends GenericPortletBean
|
||||||
// Expose current RequestAttributes to current thread.
|
// Expose current RequestAttributes to current thread.
|
||||||
RequestAttributes previousRequestAttributes = RequestContextHolder.getRequestAttributes();
|
RequestAttributes previousRequestAttributes = RequestContextHolder.getRequestAttributes();
|
||||||
PortletRequestAttributes requestAttributes = null;
|
PortletRequestAttributes requestAttributes = null;
|
||||||
if (previousRequestAttributes == null || previousRequestAttributes.getClass().equals(PortletRequestAttributes.class)) {
|
if (previousRequestAttributes == null || previousRequestAttributes.getClass().equals(PortletRequestAttributes.class) ||
|
||||||
|
previousRequestAttributes.getClass().equals(ServletRequestAttributes.class)) {
|
||||||
requestAttributes = new PortletRequestAttributes(request, response);
|
requestAttributes = new PortletRequestAttributes(request, response);
|
||||||
RequestContextHolder.setRequestAttributes(requestAttributes, this.threadContextInheritable);
|
RequestContextHolder.setRequestAttributes(requestAttributes, this.threadContextInheritable);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue