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:url.Values is not safe map #172

Merged
merged 3 commits into from
Aug 27, 2019

Conversation

hxmhlt
Copy link
Contributor

@hxmhlt hxmhlt commented Aug 26, 2019

What this PR does:
Url.Values is not safe map, so add the lock to avoid concurrent map read and map write error

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


@codecov-io
Copy link

codecov-io commented Aug 26, 2019

Codecov Report

Merging #172 into develop will increase coverage by 1.32%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           develop    #172      +/-   ##
==========================================
+ Coverage    66.57%   67.9%   +1.32%     
==========================================
  Files           90      94       +4     
  Lines         5544    5851     +307     
==========================================
+ Hits          3691    3973     +282     
- Misses        1461    1466       +5     
- Partials       392     412      +20
Impacted Files Coverage Δ
common/url.go 70.33% <50%> (-0.36%) ⬇️
config/provider_config.go 61.76% <0%> (ø) ⬆️
registry/directory/directory.go 78.3% <0%> (ø) ⬆️
remoting/zookeeper/listener.go 46.9% <0%> (ø) ⬆️
config/consumer_config.go 61.7% <0%> (ø) ⬆️
config/config_loader.go 53.73% <0%> (ø) ⬆️
filter/impl/hystrix_filter.go 68.64% <0%> (ø)
registry/consul/registry.go 69.49% <0%> (ø)
registry/consul/utils.go 71.11% <0%> (ø)
registry/consul/listener.go 81.48% <0%> (ø)
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 23b95a0...ae028f9. Read the comment docs.

@gaoxinge
Copy link

Does this fix #146?

common/url.go Outdated
}

func (c URL) GetParam(s string, d string) string {
var r string
c.paramsLock.RLock()
if r = c.Params.Get(s); r == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

'len(r) == 0' instead.

Port string
Params url.Values
//url.Values is not safe map, add to avoid concurrent map read and map write error
paramsLock sync.RWMutex
Copy link
Contributor

Choose a reason for hiding this comment

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

pls place the paramsLock before Params

@AlexStocks
Copy link
Contributor

LGTM

@AlexStocks AlexStocks merged commit dfc90b5 into apache:develop Aug 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants