From 2ba5c4b9ecd6659791fdfb19ab51a86b9670797c Mon Sep 17 00:00:00 2001 From: Bertrand Renuart Date: Thu, 11 Jun 2015 13:24:37 +0200 Subject: [PATCH] gh327: explicitly close the HttpResponse in case of timeout --- .../cloud/netflix/zuul/filters/route/RibbonCommand.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/route/RibbonCommand.java b/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/route/RibbonCommand.java index ce079ab46..4033fc068 100644 --- a/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/route/RibbonCommand.java +++ b/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/route/RibbonCommand.java @@ -131,6 +131,15 @@ public class RibbonCommand extends HystrixCommand { HttpResponse response = this.restClient .executeWithLoadBalancer(httpClientRequest); context.set("ribbonResponse", response); + + // Explicitly close the HttpResponse if the Hystrix command timed out to + // release the underlying HTTP connection held by the response. + // + if( this.isResponseTimedOut() ) { + if( response!= null ) { + response.close(); + } + } return response; }