@Test
  void doNotCloseAfterDecode() {
    server.enqueue(new MockResponse().setBody("success!"));

    String url = "http://localhost:" + server.getPort();
    Decoder decoder =
        (response, type) ->
            new Iterator<>() {
              private boolean called = false;

              @Override
              public boolean hasNext() {
                return !called;
              }

              @Override
              public Object next() {
                try {
                  return Util.toString(response.body().asReader(Util.UTF_8));
                } catch (IOException e) {
                  fail("", e.getMessage());
                  return null;
                } finally {
                  Util.ensureClosed(response);
                  called = true;
                }
              }
            };

    TestInterface api =
        Feign.builder().decoder(decoder).doNotCloseAfterDecode().target(TestInterface.class, url);
    Iterator<String> iterator = api.decodedLazyPost();

    assertThat(iterator.hasNext()).isTrue();
    assertThat(iterator.next()).isEqualTo("success!");
    assertThat(iterator.hasNext()).isFalse();

    assertThat(server.getRequestCount()).isEqualTo(1);
  }
This test ensures that the doNotCloseAfterDecode flag functions.

<p>It does so by creating a custom Decoder that lazily retrieves the response body when asked
for it and pops the value into an Iterator.

<p>Without the doNoCloseAfterDecode flag, the test will fail with a "stream is closed"
exception.
core/src/test/java/feign/FeignBuilderTest.java