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 thread-safety issue in HTTP::CookieJar loading #276

Merged
merged 1 commit into from
Feb 22, 2021

Conversation

bradrobertson
Copy link

HTTP::CookieJar uses unsafe class caching for dynamically loading cookie jar implementations. If 2 rest-client instances are instantiated at the same time, (for instance if you spawn 2 threads), then non-deterministic behaviour can occur whereby the Hash cookie jar isn't entirely loaded and cached. This sometimes raises an exception because the Hash CookieJar can't be found (it's a race condition)

See:

Forcing an instantiation of the jar onload will force the Hash CookieJar to load before the system has a chance to spawn any threads.

Note this should technically be fixed in rest-client itself however that library appears to be stagnant so we're forced to fix it here. This object should get GC'd as it's not referenced by anything

I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner.

@bradrobertson
Copy link
Author

It looks like it's just Rubocop failures on this test suite (nothing that I actually changed) Is there a standard on what you want done on PRs for this gem? Obviously my changes here aren't the reason this i failing

@nickbair-nylas
Copy link
Contributor

@bradrobertson thanks for this! Don't worry about the RuboCop failures in Travis CI--that's an item that's on our plate to clean up.

Copy link
Contributor

@nickbair-nylas nickbair-nylas left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@nickbair-nylas nickbair-nylas merged commit 9d8ced6 into nylas:main Feb 22, 2021
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.

3 participants