0

I have defined custom ErrorDecoder for Feign Client with reference to this wiki page.

In my ErrorDecoder I am reading response body by invoking response.body()

Do I need to close response in my ErrorDecoder when reading InputStream. Or Feign will handle closing of response?

I checked SynchronousMethodHandler which invokes custom error decoder. This has finally block

} finally {
    if (shouldClose) {
        Util.ensureClosed(response.body());
}

Since there is no guidelines from the wiki page.

1 Answers1

0

If you are reading the Response object directly you must close the body yourself, our you will leak resources. This is also true if you return Response objects as part of your Feign interface.

Kevin Davis
  • 1,193
  • 8
  • 14