Skip to content

Better hostname detection#927

Merged
randomanderson merged 1 commit into
masterfrom
better-hostname-detection
Jul 22, 2019
Merged

Better hostname detection#927
randomanderson merged 1 commit into
masterfrom
better-hostname-detection

Conversation

@randomanderson
Copy link
Copy Markdown
Contributor

Attempt to get hostname in the following way:

  1. Using environment variables
  2. Using the hostname command
  3. Using InetAddress.getLocalHost().getHostName() (network/DNS)

This method is faster, and generally more accurate (See this discussion). Although almost always the same, when the environment vars and network disagree, the environment vars are usually more correct.

Marked as a breaking change because there could be situations where environment variables and network are not the same and the user expects it to use the network hostname.

Testing
This is inherently difficult to test in an automated fashion: Windows/Mac/Linux differences; Spock in an IDE gives a different result than Spock on the command line (intellij doesn't forward environment vars). I did manually test in different environments.

Attempt to get hostname through environment variables and command before going to DNS
@randomanderson randomanderson added the tag: breaking change Breaking changes label Jul 22, 2019
@randomanderson randomanderson requested a review from a team as a code owner July 22, 2019 14:47
Copy link
Copy Markdown
Contributor

@tylerbenson tylerbenson 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. Nice job. I could suggest some ways to extend testing, but it probably isn't worth it.

@randomanderson randomanderson merged commit e19d402 into master Jul 22, 2019
@randomanderson randomanderson deleted the better-hostname-detection branch July 22, 2019 20:05
@tylerbenson tylerbenson added this to the 0.31.0 milestone Jul 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tag: breaking change Breaking changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants