Merge pull request #102489 from saschagrunert/http-stream-nil

Fix regression for timed-out stream cleanups
This commit is contained in:
Kubernetes Prow Robot 2021-06-03 21:59:45 -07:00 committed by GitHub
commit b24b7d5a20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -123,8 +123,11 @@ func (c *connection) Close() error {
func (c *connection) RemoveStreams(streams ...httpstream.Stream) {
c.streamLock.Lock()
for _, stream := range streams {
// It may be possible that the provided stream is nil if timed out.
if stream != nil {
delete(c.streams, stream.Identifier())
}
}
c.streamLock.Unlock()
}

View File

@ -323,6 +323,9 @@ func TestConnectionRemoveStreams(t *testing.T) {
// remove all existing
c.RemoveStreams(stream0, stream1)
// remove nil stream should not crash
c.RemoveStreams(nil)
if len(c.streams) != 0 {
t.Fatalf("should not have any streams, has %d", len(c.streams))
}