OpenFeign / feign

Feign makes writing java http clients easier
Apache License 2.0
9.49k stars 1.93k forks source link

feign.Logger doesn't close response.body() #2529

Closed nazukin-dmitrii-sravni closed 2 months ago

nazukin-dmitrii-sravni commented 2 months ago

When feign.Logger copies Response in method logAndRebufferResponse, it makes new instance of Response.Body, but it doesn't close original Response.Body. It only closes underlying InputStream in the next line. https://github.com/OpenFeign/feign/blob/9b9d74ff18f8a41a9fa9061cf56f62f62549bc94/core/src/main/java/feign/Logger.java#L128

Looks like, it could be potential leak of resources/connections. What do you think?

For example Response.Body implementation for apache hc5 is never executed.

      @Override
      public void close() throws IOException {
        try {
          EntityUtils.consume(entity);
        } finally {
          httpResponse.close();
        }