内容类型标头值导致 UnsupportedMediaType 415 OpenFeign

yuv*_*hon 5 spring spring-boot spring-cloud feign openfeign

我们最近从版本 2.0.0 升级到,在调用使用并且也具有Content-Typespring-cloud-starter-openfeign: 2.2.2 的 REST API 时遇到以下异常:consumes@RequestHeader

    feign.FeignException$UnsupportedMediaType: [415] during [POST] to [http://localhost:8080/test]
    [TestFeign#test(TestRequest,String)]: [{"timestamp":"2021-01-03T13:13:58.192+0000",
    "status":415,"error":"Unsupported Media Type",
    "message":"Invalid mime type \"application/json, application/json\": 
    Invalid token character ',' in token \"json, application/json\"","path":"/test"}] 
Run Code Online (Sandbox Code Playgroud)
我们的 Feign 接口定义如下:
@RequestMapping(value = "/test",method = RequestMethod.POST,consumes= {"application/json"},
produces={"application/json"})
void test(@RequestBody TestRequest request,@RequestHeader("Content-Type") String contentType); 
Run Code Online (Sandbox Code Playgroud)

我们进行了调查并发现,在这种情况下,两个值都按如下方式连接:

Content-Type: "application/json, application/json"
Run Code Online (Sandbox Code Playgroud)

使用时spring-cloud-starter-openfeign:2.0.0不会出现此问题。