We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 348b178 commit cfdef09Copy full SHA for cfdef09
pkg/cache/v3/linear.go
@@ -250,7 +250,14 @@ func (cache *LinearCache) SetResources(resources map[string]types.Resource) {
250
func (cache *LinearCache) GetResources() map[string]types.Resource {
251
cache.mu.RLock()
252
defer cache.mu.RUnlock()
253
- return cache.resources
+
254
+ // create a copy of our internal storage to avoid data races
255
+ // involving mutations of our backing map
256
+ resources := make(map[string]types.Resource, len(cache.resources))
257
+ for k, v := range cache.resources {
258
+ resources[k] = v
259
+ }
260
+ return resources
261
}
262
263
func (cache *LinearCache) CreateWatch(request *Request, value chan Response) func() {
0 commit comments