fixing two goroutine leaks and one panic

dependabot/go_modules/go.uber.org/atomic-1.10.0
Linhai Song 2021-12-15 22:38:25 -05:00
parent 29292aa7bd
commit 0098dbf350
2 changed files with 7 additions and 1 deletions

View File

@ -607,7 +607,9 @@ func (c *simpleHTTPClient) Do(ctx context.Context, act httpAction) (*http.Respon
select {
case <-ctx.Done():
resp.Body.Close()
if resp != nil {
resp.Body.Close()
}
<-done
return nil, nil, ctx.Err()
case <-done:

View File

@ -35,6 +35,8 @@ func TestWatch(t *testing.T) {
s := newWatchableStore(zap.NewExample(), b, &lease.FakeLessor{}, StoreConfig{})
defer func() {
b.Close()
s.Close()
s.store.Close()
os.Remove(tmpPath)
}()
@ -536,6 +538,8 @@ func TestWatchVictims(t *testing.T) {
s := newWatchableStore(zap.NewExample(), b, &lease.FakeLessor{}, StoreConfig{})
defer func() {
b.Close()
s.Close()
s.store.Close()
os.Remove(tmpPath)
chanBufLen, maxWatchersPerSync = oldChanBufLen, oldMaxWatchersPerSync