Closed underbell closed 4 months ago
it is minimal application that reproduces this issue. check it please. https://github.com/underbell/boot-validation-test
Hi @underbell,
Congratulations on submitting your first issue for the Spring Framework, and thanks for providing the sample application! 👍
Once I modified UserControllerTest
to extend ContainerTest
, I was able to confirm the behavior you've described.
As a workaround, adding the following in build.gradle
allows your tests to pass.
implementation 'jakarta.servlet:jakarta.servlet-api'
Thus, it appears that our web binding/validation support is pulling in a dependency on the Servlet API for your WebFlux-based application -- for example, potentially via Spring's ServletRequestBindingException
which extends ServletException
.
We'll investigate the cause.
Affects: after spring-web:6.1.3(boot:3.2.2)
Indeed, I confirmed that this:
Thus, this appears to be a regression introduced in Spring Framework 6.1.3.
@rstoyanchev, does that ring a bell?
I believe this is related to the fix of #31887, which introduced the use of ModelFactory
in WebFlux. This issue occurs because ModelFactory::initModel
can throw a HttpSessionRequiredException
, which extends ServletException
. I will change it to an IllegalStateException
.
@sbrannen @poutsma Thank you all. I checked the error part, but even before 6.1.2, HttpSessionRequiredException is being processed in the same way, but it does not occur I'm curious about that part, can I ask you?? https://github.com/spring-projects/spring-framework/blob/c37f685bb7ba3bad2d8ed5e2ec02c3a75082f04b/spring-web/src/main/java/org/springframework/web/method/annotation/ModelFactory.java#L118
As I said above, the ModelFactory
was not used in WebFlux before 6.1.3.
@poutsma Thank you again for your kind explanation
Affects: after spring-web:6.1.3(boot:3.2.2)
It happens with spring-security and multiple validation