Spring webflux @ModelAttribute annotated methods not working with kotlin suspend methods #30894
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
theme: kotlin
An issue related to Kotlin support
type: bug
A general bug
Milestone
I am using spring webflux with spring boot 3.1.0 and 1.1.0 io.spring.dependency-management gradle plugin(spring webflux 6.0.9).
According to documentation, spring should call methods annotated with @ModelAttribute before any @RequestMapping, and it should support reactive types for web flux. This works fine for Mono and Flux return types, but it doesn't work with kotlin suspend functions.
In the example above, methods annotated with @ModelAttribute are invoked after the @GetMapping annotated method when I debug with breakpoints.
Also, the first suspend method,even though invoked after @GetMapping, still populates the model correctly because it doesn't cause NullPointerException when rendering the view. But the second suspend method,which is also invoked after the @GetMapping, doesn't populate the model and I am getting NullPointerException when rendering the view because roles is null.
The text was updated successfully, but these errors were encountered: