I'm trying to upgrade my system from spring-cloud Hoxton.SR8 + spring-boot 2.34.-RELEASE to spring-cloud-2020.0.0 + spring-boot 2.4.1.

Some of my tests started failing upon this upgrade, and investigation shows what seems to me a rather serious issue that I'd like to bring to your attention.

I have a simple echo service that takes a query param and echoes it back. I call it with a simple Feign client:

@FeignClient(name = "echo-service")
public interface EchoClient {
    @GetMapping(path = "/echo", produces = MediaType.APPLICATION_JSON_VALUE)
    ResponseEntity<Echo> jsonEcho(@RequestParam("m") String message);
}

My test checks the Content-Type header of the response:

        String message = "Hello JSON!";
        ResponseEntity<Echo> entity = client.jsonEcho(message);
        assertThat(entity.getHeaders().getContentType()).isEqualTo(MediaType.APPLICATION_JSON);

The test fails, because response headers seem to be broken in this latest version. I don't know whence the change stems, but it seems pretty clear it won't work properly: - feign.SynchronousMethodHandler calls feign.Response#build - feign.Response converts every header key to lower case in feign.Response#caseInsensitiveCopyOf - Response (in my case) gets wrapped into a org.springframework.http.ResponseEntity - ResponseEntity's headers are case-sensitive. The assertion in the test above fails because entity.getHeaders().getContentType() is null!

Comment From: o2-mesmer

The same test passes with spring-cloud Hoxton.SR9 and spring-boot 2.3.7.RELEASE, because ResponseEntity#getHeaders eventually queries a org.springframework.util.LinkedCaseInsensitiveMap (spring-core-5.2.12.RELEASE and spring-web-5.2.12.RELEASE), which handles, as the name suggests, header keys cases-insensitively.

Comment From: martinsefcik

Maybe ResponseEntityDecoder in createResponse method should use HttpHeaders (and it's default constructor which uses LinkedCaseInsensitiveMap) instead of case sensitive LinkedMultiValueMap to build headers for ResponseEntity.

Comment From: martinsefcik

As I mentioned yesterday, It's working correctly in case I replace the following line in ResponseEntityDecoder.createResponse method: MultiValueMap<String, String> headers = new LinkedMultiValueMap<>(); with this one: HttpHeaders headers = new HttpHeaders();

Not sure if it's proper fix, but it's working at least :)

Comment From: spencergibb

PRs welcome

Comment From: o2-mesmer

@martinsefcik @spencergibb The odd thing is that ResponseEntityDecoder hasn't changed at all, so what causes the regression?

I think this is the commit that caused the modified behaviour: https://github.com/spring-projects/spring-framework/commit/3276f818519f9bde187c4ccb83653c21c2e0e7fb

Prior to that commit, the map passed by ResponseEntityDecoder would have been wrapped in a HttpHeaders instance; after it, no more. In that sense, changing ResponseEntityDecoder to create a HttpHeaders itself would seem reasonable.

Comment From: OlgaMaciaszek

@martinsefcik Please let me know if you would like to create the PR. If not, I'll add these changes.

Comment From: martinsefcik

@OlgaMaciaszek it looks like it will be much faster when you do it. As I was trying to setup local environment on my computer for spring-cloud-openfeign project, but I was not successful yet.

Comment From: o2-mesmer

Thank you!