From f252c0d04be8d7f137557d8ef04237130c4ebc22 Mon Sep 17 00:00:00 2001 From: Travis Date: Wed, 16 Oct 2019 10:59:28 -0500 Subject: [PATCH 1/2] prevent nil pointer exception when pilosa cluster does not exist --- client.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index 3cbc8d7..10c901d 100644 --- a/client.go +++ b/client.go @@ -1127,7 +1127,11 @@ func (c *Client) doRequest(host *URI, method, path string, headers map[string]st if tries == 0 { break } - c.logger.Printf("request failed with: %v status: %d, retrying after %d more time(s) after %v ", err, resp.StatusCode, tries, sleepTime) + var statusCode int + if resp != nil { + statusCode = resp.StatusCode + } + c.logger.Printf("request failed with: %v status: %d, retrying after %d more time(s) after %v ", err, statusCode, tries, sleepTime) time.Sleep(sleepTime) sleepTime *= 2 if sleepTime > c.maxRetrySleepTime { From b0afe33dcf850eab167c514b16cf5a621682b37f Mon Sep 17 00:00:00 2001 From: Travis Date: Wed, 16 Oct 2019 15:42:22 -0500 Subject: [PATCH 2/2] fix log message --- client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.go b/client.go index 10c901d..f11d68d 100644 --- a/client.go +++ b/client.go @@ -1131,7 +1131,7 @@ func (c *Client) doRequest(host *URI, method, path string, headers map[string]st if resp != nil { statusCode = resp.StatusCode } - c.logger.Printf("request failed with: %v status: %d, retrying after %d more time(s) after %v ", err, statusCode, tries, sleepTime) + c.logger.Printf("request failed with: '%v' status: %d, retrying %d more time(s) after %v ", err, statusCode, tries, sleepTime) time.Sleep(sleepTime) sleepTime *= 2 if sleepTime > c.maxRetrySleepTime {