Skip to content

AbstractJackson2HttpMessageConverter writes partial data when exception occurs during write #26246

Closed
@jdelong747

Description

@jdelong747

Affects: 5.2.10.RELEASE and later


The AbstractJackson2HttpMessageConverter.writeInteral method was modified to use a try with resources block to optimize Jackson resource management gh-25910. This now calls close on the JsonGenerator in the event of an error such as a JsonProcessingException, which flushes what was written before the error occurred to the response body. When attempting to return a customized error response from a ControllerAdvice, the response body will contain the data written before the exception was thrown concatenated with the data written by the ControllerAdvice. This leads to an invalid response being returned to the client.

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: regressionA bug that is also a regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions