From 9ac8f2a047a5c4e4ec7e250efb34561eac0a8704 Mon Sep 17 00:00:00 2001 From: fatedier Date: Mon, 25 Mar 2019 18:17:33 +0800 Subject: [PATCH] fix health check unclosed resp body, fix #1155 --- client/health/health.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/health/health.go b/client/health/health.go index 16c1a598..42924a64 100644 --- a/client/health/health.go +++ b/client/health/health.go @@ -18,6 +18,8 @@ import ( "context" "errors" "fmt" + "io" + "io/ioutil" "net" "net/http" "time" @@ -170,6 +172,8 @@ func (monitor *HealthCheckMonitor) doHttpCheck(ctx context.Context) error { if err != nil { return err } + defer resp.Body.Close() + io.Copy(ioutil.Discard, resp.Body) if resp.StatusCode/100 != 2 { return fmt.Errorf("do http health check, StatusCode is [%d] not 2xx", resp.StatusCode)