Browse Source

gh327: explicitly close the HttpResponse in case of timeout

pull/6/head
Bertrand Renuart 10 years ago committed by Spencer Gibb
parent
commit
2ba5c4b9ec
  1. 9
      spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/route/RibbonCommand.java

9
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> { @@ -131,6 +131,15 @@ public class RibbonCommand extends HystrixCommand<HttpResponse> {
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;
}

Loading…
Cancel
Save