Skip to content

MockMvcClientHttpRequestFactory swallows ServletResponse.errorMessage #26720

Closed
@gnagy

Description

If there was an error while processing a request, MockHttpServletResponse.sendError(int status, String errorMessage) only sets this.errorMessage and does not write to this.content. Conversely, MockMvcClientHttpRequestFactory only reads servletResponse.content and ignores the error message.

This results in error response bodies being swallowed in mockMVC tests which use RestTemplate with MockMvcClientHttpRequestFactory.

So, either MockHttpServletResponse.sendError() should write to the outputstream or MockMvcClientHttpRequestFactory should read something like "errorMessage or if null the content byte array".

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

in: testIssues in the test modulein: webIssues in web modules (web, webmvc, webflux, websocket)status: feedback-providedFeedback has been providedtype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions