A JSON serialization exception can lead to corrupted output being written to the OutputStream of the response. #33358
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: duplicate
A duplicate of another issue
Uh oh!
There was an error while loading. Please reload this page.
Affects: 5.3.31
Happening in the phrase of writing object returned by endpoint(controller method) to the
OutputStream
of response body.When the
ObjectWriter#writeValue(JsonGenerator g, Object value)
throw exception, eg: due to a null key of HashMap:In such case, the
ObjectWriter#close
method will be called( invoke by the try-resources statement), it will write the intermediate corrupted result to theOutputStream
.Whereafter, the
DispatcherServlet#processDispatchResult
method will triggerHandlerExceptionResolver
, which will cause a secondary writing.Stand in the perspective of the client, a corrupted response they will get.
The
{"success":true,"data":{}}
written byObjectWriter#close
, and the{"success":false}
written byHandlerExceptionResolver
.The text was updated successfully, but these errors were encountered: