From aa4a68527b3bf73f67ce0094a194bc924dda4459 Mon Sep 17 00:00:00 2001 From: Anthony Jacques Date: Tue, 13 Jun 2023 16:01:33 -0700 Subject: [PATCH 1/2] [TEST] Add object store get with context test --- test/object_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/object_test.go b/test/object_test.go index 14e0819b2..550015cd8 100644 --- a/test/object_test.go +++ b/test/object_test.go @@ -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) From 00df958187f9d1b817c4b00d145b411fe3580156 Mon Sep 17 00:00:00 2001 From: Anthony Jacques Date: Tue, 13 Jun 2023 16:02:23 -0700 Subject: [PATCH 2/2] [FIXED] Fix race condition in object store get with nats context Close #1313 --- object.go | 1 + 1 file changed, 1 insertion(+) diff --git a/object.go b/object.go index 6bce60575..9d558cc6e 100644 --- a/object.go +++ b/object.go @@ -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():