Description
Problem scenario
The problem occurs if you have an endpoint interface method that defines multiple values @Produces
annotation, e. g.:
@Produces({"application/xml", "application/json"})
When you define an explicit decoder for the feign client, e. g. JacksonDecoder, this can result in a runtime error if the server actually sends the response in the wrong format (e. g. XML in this example). I think, the behaviour is even non-deterministic in this scenario.
Problem cause
The method "handleProducesAnnotation" of the class "JAXRSContract.java" adds both produces values to the "Accept" header, which is incorrect from my point fo view. This was different in older versions (including 9.7.0), where only the first value in the @Produces
annotation was added as the Accept header.
I think, the implementation should be reverted to the previous logic or at lease the bheaviour should be configurable. However, I don't see any benefits to include to 2 different values in the Accept header, as then the client needs to provide a decoder, which can handle both. This probably possibe in case of xml and json, but there can be other media types, which make it impossible to decide, which decoder to use.