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 3be3eb2 commit b9a28c5
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 b9a28c5

Please sign in to comment.