getLocalHost and localhost fail

View: New views
2 Messages — Rating Filter:   Alert me  

getLocalHost and localhost fail

by Claude Vittoria :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I get an issue with getLocalHost. I trace and I see getLocalHostname
return localhost and after the call at getbyname, getallbyname then
getHostbyName !?! and fails. I see with strace a request to the
nameserver ?!?

My question why the nameserver is called to resolv localhost ?

Why in InetAddress.java l.579 the test:
if (hostname == null || hostname.length() == 0)

is not
if (hostname == null || hostname.length() == 0 || "locahost".equals(hostname))

Thanks for your light.

Cheers,
Claude


Re: getLocalHost and localhost fail

by Andrew Haley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Claude Vittoria wrote:

> I get an issue with getLocalHost. I trace and I see getLocalHostname
> return localhost and after the call at getbyname, getallbyname then
> getHostbyName !?! and fails. I see with strace a request to the
> nameserver ?!?
>
> My question why the nameserver is called to resolv localhost ?

Java calls the resolver library.

> Why in InetAddress.java l.579 the test:
> if (hostname == null || hostname.length() == 0)
>
> is not
> if (hostname == null || hostname.length() == 0 || "locahost".equals(hostname))

Because there isn't any need, as far as I can see.

Andrew.