From 73d86bf3a13455ea48650bcf8bc793b34e5033e6 Mon Sep 17 00:00:00 2001 From: Mike Smith Date: Wed, 8 Jun 2016 11:20:05 +1000 Subject: [PATCH] Fix for #127 Handle the case where the hystrix RibbonCommand timed-out before the ribbon client received a response from origin. So in this situation we want to release the connection now, as we know that the zuul filter chain has already continued without us and therefore won't cleanup itself. --- .../zuul/dependency/ribbon/hystrix/RibbonCommand.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/zuul-netflix/src/main/java/com/netflix/zuul/dependency/ribbon/hystrix/RibbonCommand.java b/zuul-netflix/src/main/java/com/netflix/zuul/dependency/ribbon/hystrix/RibbonCommand.java index 512fb9a7b8..4eaa4614bc 100644 --- a/zuul-netflix/src/main/java/com/netflix/zuul/dependency/ribbon/hystrix/RibbonCommand.java +++ b/zuul-netflix/src/main/java/com/netflix/zuul/dependency/ribbon/hystrix/RibbonCommand.java @@ -127,8 +127,19 @@ HttpResponse forward() throws Exception { HttpResponse response = restClient.executeWithLoadBalancer(httpClientRequest); context.setZuulResponse(response); + + // Here we want to handle the case where this hystrix command timed-out before the + // ribbon client received a response from origin. So in this situation we want to + // cleanup this response (release connection) now, as we know that the zuul filter + // chain has already continued without us and therefore won't cleanup itself. + if (isResponseTimedOut()) { + response.close(); + } + return response; } + + public static class UnitTest {