Skip to content

Makes the Hosts class safe to be called from any thread#657

Merged
QuintinWillison merged 3 commits intomainfrom
feature/issue-650
Mar 3, 2021
Merged

Makes the Hosts class safe to be called from any thread#657
QuintinWillison merged 3 commits intomainfrom
feature/issue-650

Conversation

@QuintinWillison
Copy link
Copy Markdown
Contributor

Fixes #650.

Copy link
Copy Markdown
Member

@paddybyers paddybyers 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

private final boolean fallbackHostsUseDefault;
private final long fallbackRetryTimeout;

private final Preferred preferred = new Preferred();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm a bit surprised you didn't go for the option of Preferred being immutable, with preferred non-final.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this was movement of state and the logic around mutating that state, as much for my own benefit to break the moving parts down a bit further... but, you're right, I could still have explored an immutable Preferred, as you say, with methods that return a new instance or the same instance as appropriate.

For speed of delivery right now I'm going to leave it as is but I appreciate the observation. 😁

@QuintinWillison QuintinWillison merged commit 9376838 into main Mar 3, 2021
@QuintinWillison QuintinWillison deleted the feature/issue-650 branch March 3, 2021 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Hosts class is not thread safe

2 participants