resources: Use default math/rand.Source for concurrency safety
authorEmmanuel T Odeke <odeke@ualberta.ca>
Sun, 19 Sep 2021 10:18:30 +0000 (04:18 -0600)
committerGitHub <noreply@github.com>
Sun, 19 Sep 2021 10:18:30 +0000 (12:18 +0200)
The source from NewSource is documented not to be safe for
concurrency, and instead use the eefault source which is documented
as safe.

Fixes #8981

resources/resource_test.go

index 571dd6de17b91663bc6bd6c36df7f49bf9d9185f..9823c064db8f3abee60b7e6ea7f8b94b068846e9 100644 (file)
@@ -19,7 +19,6 @@ import (
        "path/filepath"
        "strings"
        "testing"
-       "time"
 
        "github.com/spf13/afero"
 
@@ -189,11 +188,10 @@ func TestResourcesGetMatch(t *testing.T) {
 func BenchmarkResourcesMatch(b *testing.B) {
        resources := benchResources(b)
        prefixes := []string{"abc*", "jkl*", "nomatch*", "sub/*"}
-       rnd := rand.New(rand.NewSource(time.Now().Unix()))
 
        b.RunParallel(func(pb *testing.PB) {
                for pb.Next() {
-                       resources.Match(prefixes[rnd.Intn(len(prefixes))])
+                       resources.Match(prefixes[rand.Intn(len(prefixes))])
                }
        })
 }