Skip to content

Commit

Permalink
etcd: Workaround a nil ptr bug
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
purpleidea committed Jan 18, 2019
1 parent bf63d2e commit 9398dee
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9398dee

Please sign in to comment.