When using Spring together with Open-Feign to POST a binary Spring org.springframework.core.io.Resource the SpringEncoder.encode() does not honor the charset as being set to null. This is only done for ByteArrayHttpMessageConverter or ProtobufHttpMessageConverter.

Comment From: OlgaMaciaszek

Hello, @maverick1601. Please provide a minimal, complete, verifiable example that reproduces the issue. Please add a link to the sample repo.

Comment From: maverick1601

I have documented the behavior in the following test-case: https://github.com/maverick1601/encoder-sample/blob/master/src/test/kotlin/de/digitalfrontiers/spring/encoder/SpringEncoderTest.kt

The test uses two different upload mechanisms: byte array vs. spring resource. While byte array content is properly sent to the REST controller, the Spring resource is not. This is due to the SpringEncoder setting charset UTF-8 encoding and the Apache Http Client picking up this setting and interpreting the content as string. So, in fact, the problem with the SpringEncoder only affects certain HTTP-client. If you were to remove feign-httpclient dependency (favoring JDK HttpUrlConnection) the problem doesn't even show up, as the client implementation does not inspect the charset.

Comment From: ghost

If I'm not mistaken, this is the same bug as #357 . If that's the case, then repro steps and some proposed solutions can be found there as well.

Comment From: OlgaMaciaszek

Yes, @Rob-HCL, looks like a duplicate. Closing in favour of gh-357.