From 91b74a04d6a385e95f5b7787848db1beaf61c0c8 Mon Sep 17 00:00:00 2001 From: Elim Tsiagbey Date: Tue, 1 Aug 2023 10:19:12 -0400 Subject: [PATCH] chore: BSR container close check (#3528) Add check to make sure container isn't nil before `container.close()` is called --- internal/bsr/bsr.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/internal/bsr/bsr.go b/internal/bsr/bsr.go index 86f7e3c9b8..3078168422 100644 --- a/internal/bsr/bsr.go +++ b/internal/bsr/bsr.go @@ -246,7 +246,10 @@ func OpenSession(ctx context.Context, sessionRecordingId string, f storage.FS, k // Close closes the Session container. func (s *Session) Close(ctx context.Context) error { - return s.container.close(ctx) + if !is.Nil(s.container) { + return s.container.close(ctx) + } + return nil } // Connection is a container in a bsr for a specific connection in a session @@ -518,7 +521,10 @@ func (c *Connection) NewRequestsWriter(ctx context.Context, dir Direction) (io.W // Close closes the Connection container. func (c *Connection) Close(ctx context.Context) error { - return c.container.close(ctx) + if !is.Nil(c.container) { + return c.container.close(ctx) + } + return nil } // Channel is a container in a bsr for a specific channel in a session @@ -532,7 +538,10 @@ type Channel struct { // Close closes the Channel container. func (c *Channel) Close(ctx context.Context) error { - return c.container.close(ctx) + if !is.Nil(c.container) { + return c.container.close(ctx) + } + return nil } // NewMessagesWriter creates a writer for recording channel messages.