-
Notifications
You must be signed in to change notification settings - Fork 24
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
fix: data race warnings #102
Conversation
This error occures when there is a mutex in the structure and using a method with a value reviever. In this case the struct will be copied on the method call and it will create a new mutex therefore our previous lock became useless. From the go vet doc: "copylocks: check for locks erroneously passed by value"
@@ -129,15 +129,15 @@ func newCloudPakForDataAuthenticatorFromMap(properties map[string]string) (*Clou | |||
} | |||
|
|||
// AuthenticationType returns the authentication type for this authenticator. | |||
func (CloudPakForDataAuthenticator) AuthenticationType() string { |
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.
I don't know if is there a specific reason why this used as a value or not, but hopefully changing it to pointer won't break anything. All tests passed btw.
@padamstx What's your take on this?
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.
LGTM
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.
After approving the PR, I checked on the travis build and noticed the lint error, so added a new review with comment. I'll approve now to avoid a re-review.
🎉 This PR is included in version 5.2.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Fixes arf/planning-sdk-squad#2440
Problem
There were several warnings about race conditions (mostly about the
tokenData
field) when running the unit tests.Reproduce
go test -tags=all -race
Solution
Introduced "getter" and "setter" functions for the authenticator's
tokenData
with mutex.