MockMvcClientHttpRequestFactory swallows ServletResponse.errorMessage #26720
Labels
in: test
Issues in the test module
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: feedback-provided
Feedback has been provided
type: enhancement
A general enhancement
Milestone
If there was an error while processing a request,
MockHttpServletResponse.sendError(int status, String errorMessage)
only setsthis.errorMessage
and does not write tothis.content
. Conversely, MockMvcClientHttpRequestFactory only readsservletResponse.content
and ignores the error message.This results in error response bodies being swallowed in mockMVC tests which use
RestTemplate
withMockMvcClientHttpRequestFactory
.So, either MockHttpServletResponse.sendError() should write to the outputstream or MockMvcClientHttpRequestFactory should read something like "errorMessage or if null the content byte array".
The text was updated successfully, but these errors were encountered: