Skip to content

Thread safety - #50

Open
RyanMentley wants to merge 1 commit into
kevinsawicki:masterfrom
RyanMentley:master
Open

Thread safety#50
RyanMentley wants to merge 1 commit into
kevinsawicki:masterfrom
RyanMentley:master

Conversation

@RyanMentley

Copy link
Copy Markdown

This is to improve thread safety for static methods that may be called from multiple threads.
This change does not affect the thread safety of individual HttpRequest instances.

Use ThreadLocal for trustedFactory, as the documentation for the classes used makes no thread-
safety guarantees.
Make TRUSTED_VERIFIER final and initialize lazily using the lazy initialization holder class
idiom used in Effective Java item 71, as the implementation used is thread-safe.
Make connectionFactory volatile. This requires implementers of the ConnectionFactory interface
to ensure that their implementation is thread-safe.

This also changes the static members used that were not final to use the more conventional
camelCase naming rather than ALL_CAPS.

This is to improve thread safety for static methods that may be called from multiple threads.
This change does not affect the thread safety of individual HttpRequest instances.

Use ThreadLocal for trustedFactory, as the documentation for the classes used makes no thread-
safety guarantees.
Make TRUSTED_VERIFIER final and initialize lazily using the lazy initialization holder class
idiom used in Effective Java item 71, as the implementation used is thread-safe.
Make connectionFactory volatile.  This requires implementers of the ConnectionFactory interface
to ensure that their implementation is thread-safe.

This also changes the static members used that were not final to use the more conventional
camelCase naming rather than ALL_CAPS.
@RyanMentley

Copy link
Copy Markdown
Author

Hey, just wondering if there were any issues with this pull request. I'd be happy to address any issues.

@kevinsawicki

Copy link
Copy Markdown
Owner

Nope, sorry for the delay, will merge it soon.

Do you think it is feasible to add any tests for this that will prove these changes are needed?

@rferreira

Copy link
Copy Markdown

hey folks, what are the odds of getting this merged in?

@kevinsawicki

Copy link
Copy Markdown
Owner

@rferreira are you having threading issues using this library?

@rferreira

Copy link
Copy Markdown

@kevinsawicki nope, just a small false alarm a few weeks back.

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