KYLIN-2814: fix connection may not be released when sync wipe cache Signed-off-by: Billy Liu <billy...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/5c1aab10 Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/5c1aab10 Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/5c1aab10 Branch: refs/heads/KYLIN-2814 Commit: 5c1aab101f3d5a3fb0cdc4c85c1c3f60274979fc Parents: 727920b Author: lichao <cha...@mobvoi.com> Authored: Fri Aug 25 14:31:17 2017 +0800 Committer: Billy Liu <billy...@apache.org> Committed: Thu Aug 31 15:38:31 2017 +0800 ---------------------------------------------------------------------- .../java/org/apache/kylin/common/restclient/RestClient.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kylin/blob/5c1aab10/core-common/src/main/java/org/apache/kylin/common/restclient/RestClient.java ---------------------------------------------------------------------- diff --git a/core-common/src/main/java/org/apache/kylin/common/restclient/RestClient.java b/core-common/src/main/java/org/apache/kylin/common/restclient/RestClient.java index 13490cb..efd0438 100644 --- a/core-common/src/main/java/org/apache/kylin/common/restclient/RestClient.java +++ b/core-common/src/main/java/org/apache/kylin/common/restclient/RestClient.java @@ -121,8 +121,9 @@ public class RestClient { String url = baseUrl + "/cache/" + entity + "/" + cacheKey + "/" + event; HttpPut request = new HttpPut(url); + HttpResponse response = null; try { - HttpResponse response = client.execute(request); + response = client.execute(request); if (response.getStatusLine().getStatusCode() != 200) { String msg = EntityUtils.toString(response.getEntity()); @@ -131,6 +132,9 @@ public class RestClient { } catch (Exception ex) { throw new IOException(ex); } finally { + if(response != null){ + EntityUtils.consume(response.getEntity()); + } request.releaseConnection(); } }