From ba16a808645e812b442abb10eeb90f2814aca4ff Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sun, 14 May 2017 13:56:38 +0800 Subject: [PATCH] return an error when calling OpenStream after the session was closed fixes #615 --- streams_map.go | 3 +++ streams_map_test.go | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/streams_map.go b/streams_map.go index b42c72de..d29ac80b 100644 --- a/streams_map.go +++ b/streams_map.go @@ -166,6 +166,9 @@ func (m *streamsMap) OpenStream() (*stream, error) { m.mutex.Lock() defer m.mutex.Unlock() + if m.closeErr != nil { + return nil, m.closeErr + } return m.openStreamImpl() } diff --git a/streams_map_test.go b/streams_map_test.go index 370d9b50..f810fd26 100644 --- a/streams_map_test.go +++ b/streams_map_test.go @@ -181,6 +181,13 @@ var _ = Describe("Streams Map", func() { Expect(err).To(MatchError(testErr)) }) + It("returns the error when the streamsMap was closed", func() { + testErr := errors.New("test error") + m.CloseWithError(testErr) + _, err := m.OpenStream() + Expect(err).To(MatchError(testErr)) + }) + Context("counting streams", func() { var maxNumStreams int