-
-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add RW Lock to allComponentSchemas to Prevent Data Race Error #344
Conversation
califlower
commented
Oct 24, 2024
- solves issue Data Race using GetAllComponentSchemas #333
- Accessing GetAllComponentSchemas causes a race condition error during usage.
- Adds a RWLock to ensure that the map object is safely created across go routines. This pattern is used for other similar fields
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #344 +/- ##
==========================================
- Coverage 99.62% 99.61% -0.01%
==========================================
Files 165 165
Lines 21050 21064 +14
==========================================
+ Hits 20971 20983 +12
- Misses 74 76 +2
Partials 5 5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
I can add a test here, just wasn't sure about testing the race condition it was kind of difficult |
I added a concurrent access test and a nil test. That should keep the coverage where it was at before |
RIP. Doesn't seem like codecov is correct :< |
The codecov is correct, I checked out your branch and this is what happens after running all tests. The problem is the test. func TestSpecIndex_GetAllComponentSchemas_NilIndex(t *testing.T) {
index := &SpecIndex{}
schemas := index.GetAllComponentSchemas()
assert.Nil(t, schemas, "Expected GetAllComponentSchemas to return nil when index is nil")
}
func TestSpecIndex_GetAllComponentSchemas_NilIndex(t *testing.T) {
var index *SpecIndex
schemas := index.GetAllComponentSchemas()
assert.Nil(t, schemas, "Expected GetAllComponentSchemas to return nil when index is nil")
} |
fixed invalid test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution.
Ah my bad. Thank you for fixing it and merging! Really appreciate it! |