Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reject ModelMap argument types in WebFlux #33109

Closed
sbrannen opened this issue Jun 27, 2024 · 0 comments
Closed

Reject ModelMap argument types in WebFlux #33109

sbrannen opened this issue Jun 27, 2024 · 0 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@sbrannen
Copy link
Member

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

@sbrannen sbrannen added in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement labels Jun 27, 2024
@sbrannen sbrannen added this to the 6.2.0-M5 milestone Jun 27, 2024
@sbrannen sbrannen self-assigned this Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant