Skip to content

Conversation

@mirosval
Copy link
Contributor

@mirosval mirosval commented Apr 15, 2025

With custom test runners, it's necessary to be able to use MockServer in a threaded setting, which is not possible as it is not Send. It's not Send, because it's using OnceCell which is not Send and it's using the ThreadRng which is also not Send.
This PR replaces these with their equivalent versions that are Send. Additionally it adds a small test ensuring that MockServer remains Send in the future.

Fixes #42

@mdevino
Copy link
Contributor

mdevino commented Apr 16, 2025

Hey, thanks for the PR (and the issue)!
Looks good to me, but I'd like @declark1 to take a look at it as well.

@declark1 declark1 self-requested a review April 16, 2025 16:27
Copy link
Contributor

@declark1 declark1 left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks for the contribution @mirosval. I hadn't considered a use case where the server itself would need to be Send.

@declark1
Copy link
Contributor

@mirosval would you mind rebasing your branch and running cargo fmt? The format check is failing and I made a change to drop requiring cargo +nightly fmt. Thanks!

With custom test runners, it's necessary to be able to use MockServer in a threaded setting, which is not possible as it is not `Send`. It's not `Send`, because it's using `OnceCell` which is not `Send` and it's using the `ThreadRng` which is also not `Send`.
This PR replaces these with their equivalent versions that are `Send`. Additionally it adds a small test ensuring that `MockServer` remains `Send` in the future.

Signed-off-by: Miroslav Zoricak <[email protected]>
Signed-off-by: Miroslav Zoricak <[email protected]>
@mirosval
Copy link
Contributor Author

@declark1 ran cargo fmt.

I hadn't considered a use case where the server itself would need to be Send.

You're not the only one, httpmock's server also isn't Send 🙂

@declark1 declark1 merged commit f211980 into IBM:main Apr 16, 2025
2 checks passed
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.

MockServer is not Send

3 participants