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

HostAndPort.convertHost() to resolve localhost in a lazy manner #1468

Merged
merged 1 commit into from
Jun 15, 2017

Conversation

jkrahul
Copy link
Contributor

@jkrahul jkrahul commented Feb 17, 2017

fixes #1424

@jkrahul
Copy link
Contributor Author

jkrahul commented Feb 17, 2017

There is some issue with redis dependencies in Travis. Tests passed in my local with redis unstable branch

@marcosnils
Copy link
Contributor

marcosnils commented Feb 17, 2017

LGTM @HeartSaVioR, @allanwax ?

@marcosnils marcosnils added this to the 2.10.0 milestone Feb 17, 2017
@marcosnils
Copy link
Contributor

@jkrahul can you rebase with master so tests pass please?

return host;
}
}

public static void setLocalhost(String localhost) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there any actual usages for setLocalhost()? setLocalhost() and getLocalhost() can make race condition.

Btw, getLocalhost() itself can make race condition but it might be OK given that getLocalHostQuietly() always returns same value.

Choose a reason for hiding this comment

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

@marcosnils @jkrahul The only use I can think of is a potential one. If the programmer wants to override the natural local host value, say with the ENDPOINT value, then they can make this call change it. This would be done before actually creating a Jedis instance.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jkrahul @allanwax
If we want to keep this as it is, let's leave a javadoc comment for this method describing that this method is not thread-safe so it shouldn't be used with getLocalhost() concurrently.

Copy link

Choose a reason for hiding this comment

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

Wrapping the operations inside setLocalhost and getLocalhost will make it safe and is less heavy weight than synchronized.

Choose a reason for hiding this comment

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

@marcosnills @jkrahul I was imagining the wrapping being a ReentrantLock. I'm good .

@HeartSaVioR
Copy link
Contributor

@jkrahul I've done reviewing and left comment.

@HeartSaVioR
Copy link
Contributor

@jkrahul Please rebase and address review comment. Thanks in advance!

@jkrahul
Copy link
Contributor Author

jkrahul commented Mar 11, 2017

@marcosnils @HeartSaVioR @allanwax review comments have been addressed. Please check

@marcosnils
Copy link
Contributor

I believe we're good now. @allanwax @HeartSaVioR ?

@HeartSaVioR
Copy link
Contributor

@marcosnils Yes LGTM.

@HeartSaVioR
Copy link
Contributor

Merged to master and 2.10 respectively. @jkrahul Thanks for contribution!

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.

Jedis should not require localhost to be resolved so it can run clean in serverless env
4 participants