@Override
  public Object decode(Response response, Type type) throws IOException, FeignException {
    if (!isStream(type)) {
      if (!delegateDecoder.isPresent()) {
        throw new IllegalArgumentException(
            "StreamDecoder supports types other than stream. "
                + "When type is not stream, the delegate decoder needs to be setting.");
      } else {
        return delegateDecoder.get().decode(response, type);
      }
    }
    ParameterizedType streamType = (ParameterizedType) type;
    Iterator<?> iterator =
        (Iterator<?>) iteratorDecoder.decode(response, new IteratorParameterizedType(streamType));

    return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, 0), false)
        .onClose(
            () -> {
              if (iterator instanceof Closeable) {
                ensureClosed((Closeable) iterator);
              } else {
                ensureClosed(response);
              }
            });
  }
Iterator based decoder that support streaming.

<p>

<p>Example: <br>

<pre>
<code>
Feign.builder()
  .decoder(StreamDecoder.create(JacksonIteratorDecoder.create()))
  .doNotCloseAfterDecode() // Required for streaming
  .target(GitHub.class, "https://api.github.com");
or
Feign.builder()
  .decoder(StreamDecoder.create(JacksonIteratorDecoder.create(), (r, t) -> "hello world")))
  .doNotCloseAfterDecode() // Required for streaming
  .target(GitHub.class, "https://api.github.com");
interface GitHub {
 {@literal @}RequestLine("GET /repos/{owner}/{repo}/contributors")
  Stream<Contributor> contributors(@Param("owner") String owner, @Param("repo") String repo);
}</code>
</pre>
core/src/main/java/feign/stream/StreamDecoder.java