From 1e3c7710a9bcd56d659a17eccaba3d5765ce3c5d Mon Sep 17 00:00:00 2001 From: Mark Mandel Date: Tue, 8 Sep 2020 16:42:21 -0700 Subject: [PATCH] Add lock to to sdk-conformance compare() Likely isn't an issue, but figure it wouldn't hurt, and probably should be there anyway. --- pkg/sdkserver/localsdk.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/sdkserver/localsdk.go b/pkg/sdkserver/localsdk.go index b8c2cac7ba..cbf10ad448 100644 --- a/pkg/sdkserver/localsdk.go +++ b/pkg/sdkserver/localsdk.go @@ -615,8 +615,12 @@ func (l *LocalSDKServer) EqualSets(expected, received []string) bool { // compare the results of a test run func (l *LocalSDKServer) compare() { if l.testMode { + l.testMutex.Lock() + defer l.testMutex.Unlock() if !l.EqualSets(l.expectedSequence, l.requestSequence) { l.logger.WithField("expected", l.expectedSequence).WithField("received", l.requestSequence).Info("Testing Failed") + // we don't care if the mutex gets unlocked on exit, so ignore the warning. + // nolint: gocritic os.Exit(1) } else { l.logger.Info("Received requests match expected list. Test run was successful")