Fix issue with creating ServletRequestAttributes

Prevously the FrameworkServlet created a new ServletRequestAttributes
instance for every request, unless the RequestContextHolder already
contained an instance whose type is not ServletRequestAttributes.
The main intent was that if RequestContextHolder contains a
PortletRequestAttributes, it should be left in place.

This change does an "instanceof" check against the request in
RequestContextHolder instead of an "equals" check on the type.
It still leaves PortletRequestAttributes in place but also allows
the previous request to be any sub-class of ServletRequestAttributes.

Issue: SPR-10025
This commit is contained in:
Rossen Stoyanchev
2012-12-07 15:19:38 -05:00
parent 69ace01640
commit 3643d92cb8
3 changed files with 102 additions and 13 deletions

View File

@@ -904,7 +904,7 @@ public abstract class FrameworkServlet extends HttpServletBean {
RequestAttributes previousAttributes = RequestContextHolder.getRequestAttributes();
ServletRequestAttributes requestAttributes = null;
if (previousAttributes == null || previousAttributes.getClass().equals(ServletRequestAttributes.class)) {
if (previousAttributes == null || (previousAttributes instanceof ServletRequestAttributes)) {
requestAttributes = new ServletRequestAttributes(request);
}