-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Description
Overview
org.springframework.web.servlet.view.UrlBasedViewResolver.buildView(String) and org.springframework.web.reactive.result.view.UrlBasedViewResolver.createView(String) both override the requestContextAttribute in the created View even if the requestContextAttribute in the UrlBasedViewResolver is null.
Consequently if a custom subclass of org.springframework.web.servlet.view.AbstractView or org.springframework.web.reactive.result.view.AbstractUrlBasedView configures the requestContextAttribute, it will be overwritten with null if the view is dynamically instantiated by a UrlBasedViewResolver. On the other hand, the custom configured requestContextAttribute will remain in tact if the view is used outside of a UrlBasedViewResolver, and this subtle difference can lead to unexpected results.
If the user explicitly configures the requestContextAttribute for a UrlBasedViewResolver, the user is probably (hopefully) aware of the effect. However, if the user does not explicitly configure the requestContextAttribute for a UrlBasedViewResolver we should not overwrite any custom configuration with null.
Deliverables
- Only propagate a non-null
requestContextAttributeto a dynamically instantiatedViewinUrlBasedViewResolverinspring-webmvc. - Only propagate a non-null
requestContextAttributeto a dynamically instantiatedViewinUrlBasedViewResolverinspring-webflux.