Describe the bug If we add add a header named abc with value {x:1.0,y:1.1} to OpenFeign RestTemplate, and get it to print, the final value will be {x:1.0,y}. That means :1.1 is lost.

This issue happens on Spring Cloud 2021.0.4.0, Spring Cloud 2020.0.6 and Hoxton.SR12 works fine.

Please take a look for it. Thanks

Sample

RequestInterceptor code as follows

import feign.RequestInterceptor;
import feign.RequestTemplate;

public class MyRequestInterceptor implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate requestTemplate) {
        String headerName = "abc";
        String headerValue = "{x:1.0,y:1.1}";

        System.out.println("--- Before adding: " + headerName + " = " + headerValue);

        requestTemplate.header(headerName, headerValue);

        String headerValueInRequestTemplate = requestTemplate.headers().get(headerName).toString();

        System.out.println("=== Get value after Adding: " + headerName + " = " + headerValueInRequestTemplate);
    }
}

Create the bean in your configuration

@Bean
public MyRequestInterceptor myRequestInterceptor() {
    return new MyRequestInterceptor();
 }

Comment From: HaojunRen

Refer to runing result

Spring Cloud 2021

1664346524750

Spring Cloud 2020

1664346274105

Comment From: HaojunRen

The header value starting with { will be considerd with an expression, it does not make sense,because header value will be often a json format.

1664349792390

Comment From: OlgaMaciaszek

Hello, @HaojunRen. Thanks for providing the sample and sorry for not getting back to you earlier. I was able to reproduce the behaviour you've described. However, this happens while executing header(...) method on Feign RequestTemplate, which are part of the third-party Feign project. We only provide additional integrations and functionalities on top of it. You might want to create an issue in the OpenFeign/Feign repo instead.

Comment From: kdavisk6

From the feign side, the issue here is the values being provided in the header are not valid JSON. The parameter names are not quoted properly, so the value in Feign is being truncated.

Comment From: HaojunRen

Suggest to upgrade OpenFeign version to 12.0+ ASAP, It seems to fix an important bug. Refer to - https://github.com/OpenFeign/feign/issues/1464 - https://github.com/OpenFeign/feign/issues/1987 - https://github.com/OpenFeign/feign/pull/1638

Comment From: OlgaMaciaszek

@HaojunRen We're on Feign 12.5 on main (plans to upgrade to 13.0) and 12.4 on 4.0.x (plans to upgrade it to 12.5). 3.1.x will stay compatible with 11.x line, and its the OSS support is only for a few more days.