RFR: 7166687: InetAddress.getLocalHost().getHostName() returns FQDN
Alan Bateman
Alan.Bateman at oracle.com
Sat May 5 14:22:54 PDT 2012
On 05/05/2012 18:47, Rob McKenna wrote:
> Hi folks,
>
> A typo in the MacOSX work led to a regression in b11 of 7u4.
> Specifically:
>
> http://hg.openjdk.java.net/jdk7u/jdk7u/jdk/diff/5cca2f1a37da/src/solaris/native/java/net/Inet6AddressImpl.c
>
>
> As per the bug report the && in the 2nd #if macro meant that this
> condition was ignored and the solaris code was used instead. I.e.
> getnameinfo to was used to do the lookup whereas Linux previously used
> gethostname with the effect that a call to
> InetAddress.getLocalHost().getHostName() now returned the fqdn instead
> of the hostname alone.
>
> webrevs for 7 & 8 (identical): http://cr.openjdk.java.net/~robm/7166687/
I don't think this is a bug, it's always been highly
platform/configuration specific as to whether the hostname contains a
domain or not (meaning applications shouldn't make this assumption).
That said, this is a behavior change in 7u4 that was missed, and we try
to avoid behavior changes like this in update releases. So the change in
the webrev looks fine to me and fixes the obvious error that crept in
when the Mac port was pushed.
-Alan.
More information about the net-dev
mailing list