From 9398deeabcfe278ffb96a75770e0098944484859 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Thu, 17 Jan 2019 19:45:52 -0500 Subject: [PATCH] etcd: Workaround a nil ptr bug A clean re-write of this etcd code is needed, but until then, this should hopefully workaround the occasional test failures. In practice I don't think anyone has every hit this bug. --- etcd/etcd.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/etcd/etcd.go b/etcd/etcd.go index 2555f346..af7703bd 100644 --- a/etcd/etcd.go +++ b/etcd/etcd.go @@ -1049,6 +1049,15 @@ func (obj *EmbdEtcd) rawGet(ctx context.Context, gq *GQ) (result map[string]stri log.Printf("Trace: Etcd: rawGet()") } obj.rLock.RLock() + // TODO: we're checking if this is nil to workaround a nil ptr bug... + if obj.client == nil { // bug? + obj.rLock.RUnlock() + return nil, fmt.Errorf("client is nil") + } + if obj.client.KV == nil { // bug? + obj.rLock.RUnlock() + return nil, fmt.Errorf("client.KV is nil") + } response, err := obj.client.KV.Get(ctx, gq.path, gq.opts...) obj.rLock.RUnlock() if err != nil || response == nil {