Skip to content

Commit a8a6b5f

Browse files
author
Linus Arver
committed
cache_test: fix data race
This was found by running go test -race k8s.io/test-infra/prow/cache
1 parent 4885135 commit a8a6b5f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

prow/cache/cache_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,13 @@ func TestCallbacks(t *testing.T) {
341341
forcedEvictionsCounter := 0
342342
manualEvictionsCounter := 0
343343

344+
counterLock := &sync.Mutex{}
344345
mkCallback := func(counter *int) EventCallback {
345-
callback := func(key interface{}) { (*counter)++ }
346+
callback := func(key interface{}) {
347+
counterLock.Lock()
348+
(*counter)++
349+
counterLock.Unlock()
350+
}
346351
return callback
347352
}
348353

0 commit comments

Comments
 (0)