Skip to content

Commit

Permalink
Merge pull request #1314 from anthonyjacques20/main
Browse files Browse the repository at this point in the history
Fix Race condition in object store with nats context
  • Loading branch information
wallyqs authored Jun 13, 2023
2 parents b2d067b + 00df958 commit ad14f4d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions object.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ func (obs *obs) Get(name string, opts ...GetObjectOpt) (ObjectResult, error) {
result.digest = sha256.New()

processChunk := func(m *Msg) {
var err error
if ctx != nil {
select {
case <-ctx.Done():
Expand Down
6 changes: 6 additions & 0 deletions test/object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ func TestObjectBasics(t *testing.T) {
expectOk(t, result.Error())
defer result.Close()

// Now get the object back with a context option.
result, err = obs.Get("BLOB", nats.Context(context.Background()))
expectOk(t, err)
expectOk(t, result.Error())
defer result.Close()

// Check info.
info, err = result.Info()
expectOk(t, err)
Expand Down

0 comments on commit ad14f4d

Please sign in to comment.