handleEmptyBody of RequestBodyAdvice should apply also when content-type is not set #30522
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
Milestone
The code that determines whether to run handleEmptyBody depends on other factors besides the body not being provided. I have attached a simple application that shows the issue (test.zip). The application is comprised of 1 controller and 1 advice.
If the endpoint is called without a body and no content type, the advice will not run (note that the endpoint returns 200):
If the endpoint is called without a body but with a content type, the advice will run (note that the endpoint returns 200):
If we inspect
AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters()
we see that in the first case the content type is set toapplication/octet-stream
while in the second it is set toapplication/json
. The converter is not able to handleapplication/octet-stream
so theif
andhandleEmptyBody
will not run. Sending the content type header is unnecessary when there is no body, so the behaviour of runninghandleEmptyBody
shouldn't depend on it.The text was updated successfully, but these errors were encountered: