On Sun, 17 Oct 2021 21:39:06 GMT, Mark Sheppard <mshep...@openjdk.org> wrote:

> I think that a hostname is constant while a host is up, but it can be 
> changed, and when changed a host restart is required. I don't think it is 
> quite as dynamic as has been suggested, but I open to correction.

It is possible to change a host name without host restart. What has been tested:
- Checked O/S type - Linux
- `hostnamectl` cmd was used to change a host name
- In output below there is only one `jshell` instance running.


jshell> InetAddress.getLocalHost()
$1 ==> test-host-name/192.168.0.155

$ hostnamectl set-hostname 'test-host-name-changed'

# Need to sleep for 5 seconds since local host
# is cached for 5 seconds since last resolution
$ sleep 5

jshell> InetAddress.getLocalHost()
$2 ==> test-host-name-changed/192.168.0.155


I believe it proves that we need to treat a host name as dynamically changing 
information.

-------------

PR: https://git.openjdk.java.net/jdk/pull/5822

Reply via email to