Skip to content

Reject ModelMap argument types in WebFlux #33109

Closed
@sbrannen

Description

Overview

Although ModelMap is not officially supported as an argument type for a WebFlux controller method, it still possible for a user to accidentally attempt to use ModelMap instead of Model or Map.

If ModelMap is used, the user currently encounters an exception similar to the following.

java.lang.IllegalStateException: argument type mismatch
Controller [org.springframework.web.reactive.config.WebFluxViewResolutionIntegrationTests$SampleController]
Method [java.lang.String org.springframework.web.reactive.config.WebFluxViewResolutionIntegrationTests$SampleController.index(org.springframework.ui.ModelMap)] with argument values:
 [0] [type=org.springframework.validation.support.BindingAwareConcurrentModel] [value={}]

The above is a bit cryptic since the error occurs while attempting to invoke the controller method with an instance of BindingAwareConcurrentModel which is not compatible with ModelMap.

Thus, we should improve diagnostics for the user in such scenarios by rejecting the use of ModelMap upfront in the ModelMethodArgumentResolver in WebFlux.

Related Issues

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions