Skip to content

Concurrent map writes error in RegisterBodyEncoder #917

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

Closed
natehart opened this issue Feb 29, 2024 · 1 comment · Fixed by #934
Closed

Concurrent map writes error in RegisterBodyEncoder #917

natehart opened this issue Feb 29, 2024 · 1 comment · Fixed by #934

Comments

@natehart
Copy link
Contributor

The bodyEncoders map is not thread safe. If encoders are registered in parallel, this line can cause a fatal "concurrent map writes" error. I discovered this due to having parallel tests that each used a new instance of my rest server.

This is likely low priority as this should't really ever happen in production code, but it's probably still worth making this map thread safe by adding a read-write mutex to guard all functions that access that map.

@fenollp
Copy link
Collaborator

fenollp commented Apr 6, 2024

A sync.RWMutex should do it indeed

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 a pull request may close this issue.

2 participants