Skip to content

Commit

Permalink
Update MockFragment Stats method
Browse files Browse the repository at this point in the history
The changes include synchronizing access to the underlying map when calculating the Length stat in the MockFragment's Stats() method. This is to ensure thread safety while accessing shared resources.
  • Loading branch information
buraksezer committed May 10, 2024
1 parent f93bc87 commit 81e1254
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/testutil/mockfragment/mockfragment.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ func New() *MockFragment {
}

func (f *MockFragment) Stats() storage.Stats {
return storage.Stats{}
f.Lock()
defer f.Unlock()
return storage.Stats{
Length: len(f.m),
}
}

func (f *MockFragment) Name() string {
Expand Down

0 comments on commit 81e1254

Please sign in to comment.