gh327: explicitly close the HttpResponse in case of timeout

This commit is contained in:
Bertrand Renuart
2015-06-11 13:24:37 +02:00
committed by Spencer Gibb
parent 440779bcf0
commit 2ba5c4b9ec

View File

@@ -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;
}