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

DefaultParameters collection is not read-only #2025

Closed
alexeyzimarev opened this issue Mar 13, 2023 · 0 comments · Fixed by #2039
Closed

DefaultParameters collection is not read-only #2025

alexeyzimarev opened this issue Mar 13, 2023 · 0 comments · Fixed by #2039

Comments

@alexeyzimarev
Copy link
Member

The DefaultParameters property of RestClient has the ParametersCollection type. Although it's a read-only collection, it exposes public methods to add and remove parameters.

When using RestClient.AddDefaultParameter method, the collection is updated in a locked scope. However, it is possible to manipulate the collection directly by calling client.DefaultParameters.AddParameter, and it will be execute without locking the collection. It basically makes the client not thread-safe if default parameters are updated this way. It's not an intended use of the collection, but it has a public API, which allows people to do that.

My suggestion is to make the DefaultParameters property internal or private. The AddDefaultParameter might need to be added to the interface.

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

Successfully merging a pull request may close this issue.

1 participant