Florian Rampp opened SPR-7381 and commented
If a controller method returns a ResponseEntity, and this entity is created with the constructor ResponseEntity(MultiValueMap<String, String> headers, HttpStatus statusCode) the passed headers are ignored and do not appear in the resulting HTTP response.
I suppose that the reason for this is an error in the class AnnotationMethodHandlerAdapter, line 916:
if (body != null) {
writeWithMessageConverters(body, inputMessage, outputMessage);
}
If the body of the response entity is null, the message is not written.
If I use the constructor ResponseEntity(T body, MultiValueMap<String, String> headers, HttpStatus statusCode), the headers appear as expected.
Affects: 3.0.3
Referenced from: commits c24ffc9