Skip to content
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

Merged
merged 8 commits into from
Mar 30, 2021
Merged

fix: data race warnings #102

merged 8 commits into from
Mar 30, 2021

Conversation

pyrooka
Copy link
Member

@pyrooka pyrooka commented Mar 25, 2021

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.

@CLAassistant
Copy link

CLAassistant commented Mar 25, 2021

CLA assistant check
All committers have signed the CLA.

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 {
Copy link
Member Author

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?

@padamstx padamstx self-requested a review March 26, 2021 22:16
Copy link
Member

@padamstx padamstx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@padamstx padamstx left a 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.

v5/core/base_service_test.go Outdated Show resolved Hide resolved
@padamstx padamstx merged commit 9e0fcc3 into IBM:main Mar 30, 2021
ibm-devx-automation pushed a commit that referenced this pull request Mar 30, 2021
## [5.2.1](v5.2.0...v5.2.1) (2021-03-30)

### Bug Fixes

* avoid data race warnings ([#102](#102)) ([9e0fcc3](9e0fcc3))
* update go-openapi/strfmt dependency ([#104](#104)) ([018a475](018a475))
@ibm-devx-automation
Copy link

🎉 This PR is included in version 5.2.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants