Patch: java.net.InetAddress

Michael Koch konqueror@gmx.de
Fri Nov 28 22:17:00 GMT 2003


On Fri, Nov 28, 2003 at 05:09:42PM -0500, Jeff Sturm wrote:
> 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.

Yes I have it compared to SUNs JDK 1.4.2. When offline SUNs version
directly returns and InetAddress returns "0.0.0.0" for the host.

Before the patch libgcj blocked for some seconds and then returned
"0.0.0.0". With this patch applied it returns imidiately. Now libgcj
behaves the same as SUNs JDK 1.4.2.


Michael



More information about the Java-patches mailing list