Closed
Description
Affects: <Spring Framework 6.1.8 and maybe other versions>
I write a simple demo below, I write a Controller with a handler method receiving a post request and consume a valid request body
@RestController
class Controller {
@PostMapping("/test")
fun test(@RequestBody @Valid foo: Foo) {
println(foo)
}
@ExceptionHandler(Exception::class)
fun handleException(e: Exception) {
println(e)
}
}
data class Foo(
@field:NotEmpty
val name: String
)
Then I send a post request with this body to the application.
{
"name": ""
}
Check out the console and you can see a exception printed and it's type is WebExchangeBindException
But according to the spring document validation, it should throw a MethodArgumentNotValidException
.
I also test this behavior in mvc and it's the expected exception.