FrameworkPortlet exposes local PortletRequestAttributes in case of pre-bound ServletRequestAttributes as well

Issue: SPR-11295
This commit is contained in:
Juergen Hoeller 2014-06-24 21:20:57 +02:00
parent 938a2846c8
commit 2d892da641
1 changed files with 3 additions and 1 deletions

View File

@ -44,6 +44,7 @@ import org.springframework.context.i18n.SimpleLocaleContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.web.context.request.RequestAttributes;
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.PortletApplicationContextUtils;
import org.springframework.web.portlet.context.PortletRequestAttributes;
@ -516,7 +517,8 @@ public abstract class FrameworkPortlet extends GenericPortletBean
// Expose current RequestAttributes to current thread.
RequestAttributes previousRequestAttributes = RequestContextHolder.getRequestAttributes();
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);
RequestContextHolder.setRequestAttributes(requestAttributes, this.threadContextInheritable);
}