Skip to content

Commit ae1e901

Browse files
SongZhen0704sharang
authored andcommitted
[controller] fix bug - health check api should check response if null
1 parent d1c0b6e commit ae1e901

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

server/controller/monitor/common.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ func isActive(urlPrefix string, ip string, port int) bool {
4747
} else if response.StatusCode != http.StatusOK {
4848
log.Warning("curl (%s) failed, (%d)", url, response.StatusCode)
4949
}
50-
defer response.Body.Close()
50+
if response != nil && response.Body != nil {
51+
response.Body.Close()
52+
}
5153
return err == nil && response.StatusCode == http.StatusOK
5254
}

0 commit comments

Comments
 (0)