Patch: java.net.InetAddress

Jeff Sturm jsturm@one-point.com
Fri Nov 28 22:09:00 GMT 2003


On Thu, 27 Nov 2003, Michael Koch wrote:
> InetAddress.lookup() has the problem that is looks up all addresses given to
> it. Even "0.0.0.0" is looked up. DNS severs tend to just return 0.0.0.0 as
> address. GLIBC doesnt seem to do this. When you have no access to a nameserver
> the lookup method blocks until a timeout occurs (normally 5 seconds or so).
> This mainly occurs on offline systems.

Hi Michael.  I'm afraid I don't quite understand the motivation
for this patch.  Empirically, Sun's JRE always performs a lookup for e.g.

  InetAddress.getByName("0.0.0.0").getHostName();

And libgcj does the same.  (In fact the root nameservers do not return
"0.0.0.0" but NXDOMAIN, since there is no record at all for 0.in-addr.arpa.)

If you have no access to a nameserver, the resolver libraries (in glibc)
should return immediately, if your network is properly configured.  Or in
the case of no network except loopback, a query should immediately fail
with EHOSTUNREACH or similar.

> To circumvent this timeout I rewrite lookup() to just return when it is asked
> for "0.0.0.0".

I have no objection to this patch per se, but I'm curious if you compared
behavior to another VM, and how exactly they differ.  You didn't include a
test case so I could be looking at something altogether different.

Jeff



More information about the Java-patches mailing list