Skip to content

Commit

Permalink
chore: BSR container close check (#3528)
Browse files Browse the repository at this point in the history
Add check to make sure container isn't nil before `container.close()` is called
  • Loading branch information
elimt committed Aug 1, 2023
1 parent 416c0a4 commit 706ee2a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions internal/bsr/bsr.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,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
Expand Down Expand Up @@ -477,7 +480,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
Expand All @@ -490,7 +496,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.
Expand Down

0 comments on commit 706ee2a

Please sign in to comment.