Skip to content

Commit

Permalink
Merge pull request #102489 from saschagrunert/http-stream-nil
Browse files Browse the repository at this point in the history
Fix regression for timed-out stream cleanups
  • Loading branch information
k8s-ci-robot committed Jun 4, 2021
2 parents 38783bf + f2ca9c1 commit b24b7d5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Expand Up @@ -123,7 +123,10 @@ func (c *connection) Close() error {
func (c *connection) RemoveStreams(streams ...httpstream.Stream) {
c.streamLock.Lock()
for _, stream := range streams {
delete(c.streams, stream.Identifier())
// It may be possible that the provided stream is nil if timed out.
if stream != nil {
delete(c.streams, stream.Identifier())
}
}
c.streamLock.Unlock()
}
Expand Down
Expand Up @@ -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))
}
Expand Down

0 comments on commit b24b7d5

Please sign in to comment.