UrlBasedViewResolvers should not override custom requestContextAttribute with null #23129
Closed
2 tasks
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
Milestone
Overview
org.springframework.web.servlet.view.UrlBasedViewResolver.buildView(String)
andorg.springframework.web.reactive.result.view.UrlBasedViewResolver.createView(String)
both override therequestContextAttribute
in the createdView
even if therequestContextAttribute
in theUrlBasedViewResolver
isnull
.Consequently if a custom subclass of
org.springframework.web.servlet.view.AbstractView
ororg.springframework.web.reactive.result.view.AbstractUrlBasedView
configures therequestContextAttribute
, it will be overwritten withnull
if the view is dynamically instantiated by aUrlBasedViewResolver
. On the other hand, the custom configuredrequestContextAttribute
will remain in tact if the view is used outside of aUrlBasedViewResolver
, and this subtle difference can lead to unexpected results.If the user explicitly configures the
requestContextAttribute
for aUrlBasedViewResolver
, the user is probably (hopefully) aware of the effect. However, if the user does not explicitly configure therequestContextAttribute
for aUrlBasedViewResolver
we should not overwrite any custom configuration withnull
.Deliverables
requestContextAttribute
to a dynamically instantiatedView
inUrlBasedViewResolver
inspring-webmvc
.requestContextAttribute
to a dynamically instantiatedView
inUrlBasedViewResolver
inspring-webflux
.The text was updated successfully, but these errors were encountered: