diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main_test.go index cd1af9b7..296cea00 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main_test.go @@ -19,6 +19,7 @@ import ( "runtime" "slices" "strings" + "sync" "testing" "time" @@ -203,11 +204,17 @@ func (w *watchKV) Keys(context.Context, ...jetstream.WatchOpt) ([]string, error) return nil, jetstream.ErrNoKeysFound } +// putIntoMu holds putInto's writes one at a time: the composition step starts its machines' runs side by side, and each may +// raise a finding into the same map. +var putIntoMu sync.Mutex + // putInto is an assign.Findings Put that keeps each finding in into, as the finding writer would, by its key and its words. func putInto(into map[string][]byte) func(mcseat.Finding) error { return func(f mcseat.Finding) error { raw, err := json.Marshal(f) + putIntoMu.Lock() into[views.FindingKey(f.Scope, f.ID, f.Kind)] = raw + putIntoMu.Unlock() return err } }