Merge pull request #13540 from songlh-psu/fixing-3

fixing one panic and two goroutine leaks
This commit is contained in:
Piotr Tabor 2021-12-21 11:03:59 +01:00 committed by GitHub
commit 69279532f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 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,7 +35,8 @@ func TestWatch(t *testing.T) {
s := newWatchableStore(zap.NewExample(), b, &lease.FakeLessor{}, StoreConfig{})
defer func() {
s.store.Close()
b.Close()
s.Close()
os.Remove(tmpPath)
}()
@ -536,7 +537,8 @@ func TestWatchVictims(t *testing.T) {
s := newWatchableStore(zap.NewExample(), b, &lease.FakeLessor{}, StoreConfig{})
defer func() {
s.store.Close()
b.Close()
s.Close()
os.Remove(tmpPath)
chanBufLen, maxWatchersPerSync = oldChanBufLen, oldMaxWatchersPerSync
}()