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

goa.adapter#logit(): remove unneeded check which would make an unsafe concurrent modification #736

Merged

Conversation

@jim-slattery-rs
Copy link
Contributor

commented Aug 22, 2016

  • logit() doesn't need to modify a.keyvals because it was already fixed up in New()
removed unneeded check which would make an unsafe concurrent modifica…
…tion

- logit() doesn't need to modify a.keyvals because it was already fixed up in New()

@jim-slattery-rs jim-slattery-rs changed the title removed unneeded check which would make an unsafe concurrent modification goa.adapter.logit(): remove unneeded check which would make an unsafe concurrent modification Aug 22, 2016

@jim-slattery-rs jim-slattery-rs changed the title goa.adapter.logit(): remove unneeded check which would make an unsafe concurrent modification goa.adapter#logit(): remove unneeded check which would make an unsafe concurrent modification Aug 22, 2016

@raphael

This comment has been minimized.

Copy link
Member

commented Aug 22, 2016

Thank you! could I convince you to add a test that would have failed prior to this fix?

@@ -76,9 +76,6 @@ func (a *adapter) logit(msg string, keyvals []interface{}, iserror bool) {
keyvals = append(keyvals, ErrMissingLogValue)
}
m := (len(a.keyvals) + 1) / 2
if len(a.keyvals)%2 != 0 {
a.keyvals = append(a.keyvals, ErrMissingLogValue)

This comment has been minimized.

Copy link
@jim-slattery-rs

jim-slattery-rs Aug 22, 2016

Author Contributor

I couldn't think of a test to add -- this line is basically unreachable code, as far as I can tell.

a.keyvals will always have an even length, thanks to the check in New(): https://github.com/jim-slattery-rs/goa/blob/72a07361f9b5491636eeacaae3b3145b6fe63e96/logging.go#L62-L64

Therefore, we fortunately don't have to check it again here, since it would anyways be unsafe to mutate a.keyvals.

@raphael

This comment has been minimized.

Copy link
Member

commented Aug 22, 2016

oh I misread the fix... looks great, thanks!

@raphael raphael merged commit 398e76a into goadesign:master Aug 22, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

ikawaha added a commit to ikawaha/goa that referenced this pull request Dec 13, 2016

removed unneeded check which would make an unsafe concurrent modifica…
…tion (goadesign#736)

- logit() doesn't need to modify a.keyvals because it was already fixed up in New()
@ikawaha ikawaha referenced this pull request Dec 13, 2016
5 of 5 tasks complete

raphael added a commit that referenced this pull request Dec 14, 2016

Backporting unmerged features/fixes to v1 branch. (#965)
* Added the ability to dynamically add/remove keys from the jwt security middleware after creation. (#818)

* Refactor JWT key resolver (#832)

To introduce new "simple" resolver.

* Add an interface instead of using testing.T (#733)

* removed unneeded check which would make an unsafe concurrent modification (#736)

- logit() doesn't need to modify a.keyvals because it was already fixed up in New()

* Modify metrics so that names are normalized to legal chars (#771)

* Add normalizeKeys() function for normalizing metric key names

* Properly synchronize updates to metrics object

* Fix setting a default value to datetime

* Add tests for a default value of datetime

* address issue #738 by creating a title for the test file

* Fix a finalize test

* Revert "Refactor JWT key resolver (#832)"

This reverts commit f6ecb66.

* Revert "Added the ability to dynamically add/remove keys from the jwt security middleware after creation. (#818)"

This reverts commit 4c7fc9d.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.