title: Spring Cloud Open Feign: Decoder for ByteArrayResource
body: <p>I have a Spring Boot Rest End Point defined in an interface to download an image</p>
  
  <pre><code>@GetMapping(value = "/{name}")
  ResponseEntity&lt;ByteArrayResource&gt; getFileByName(@PathVariable("name") String name);
  </code></pre>
  
  <p>And I use Feign Builder to invoke this end point.</p>
  
  <pre><code>Feign.builder()
      .client(new ApacheHttpClient())
      .contract(new SpringMvcContract())
      .decoder(new JacksonDecoder())
      .encoder(new JacksonEncoder())  
      .target(clazz, url)
  </code></pre>
  
  <p>On invoking, I get below error</p>
  
  <pre><code>com.fasterxml.jackson.core.JsonParseException: Unexpected character ('�' (code 65533 / 0xfffd)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
   at [Source: (BufferedReader); line: 1, column: 2]
  </code></pre>
  
  <p>When I try to invoke the end point directly from Insomnia, it works fine. But fails through Feign Builder. The response content type is <strong>image/jpeg</strong></p>
  
  <p>Is there any specific decoder in feign to handle ByteArrayResource? I tried <strong>ResponseEntityDecoder</strong>, <strong>StreamDecoder</strong> and <strong>JacksonDecoder</strong>. None of it works.</p>
  
  <p>On debugging, I see that Jackson ObjectMapper readValue fails. I tried changing the return type from ByteArraySource to byte[], didn't work either.</p>
  
  <p>Any help?</p>