United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6247501 : java.net.InetAddress cache is not disabled, even if networkaddress.cache.ttl=0

Details
Type:
Bug
Submit Date:
2005-03-29
Status:
Closed
Updated Date:
2010-04-02
Project Name:
JDK
Resolved Date:
2006-04-11
Component:
core-libs
OS:
linux,windows_98
Sub-Component:
java.net
CPU:
x86
Priority:
P3
Resolution:
Not an Issue
Affected Versions:
5.0
Fixed Versions:

Related Reports

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.4.2_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06)
Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode)


FULL OS VERSION :
Windows 98 [Version 4.10.2222]
(also known as Win98SE)

EXTRA RELEVANT SYSTEM CONFIGURATION :
This bug only occurs when the DNS server information is *not* obtained via DHCP, and is instead set manually via the TCP/IP properties (DNS Configuration tab).

A DESCRIPTION OF THE PROBLEM :
The java.net.InetAddress.getByName() in this configuration appears to always cache positive (successful) DNS lookup results, even if the "networkaddress.cache.ttl" property is set to zero.  The InetAddress API and release notes clearly indicate this should force the InetAddress to make a fresh lookup from a DNS server, as it does when the DNS server information is obtained via DHCP.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Try to disable the cache by setting "networkaddress.cache.ttl" to zero; loop making calls to InetAddress.getByName(); note the lack of DNS activity on network.  If you can't readily monitor the network activity, selecting a server that uses rotating DNS can easily illustrate the problem.

PLEASE NOTE: The Win98SE environment *must* have a static IP address and use static DNS addresses, configured via the TCP/IP properties, in order to reproduce this bug.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A fresh DNS request should be made for each iteration of the loop in the source code below.
ACTUAL -
One DNS request is made for the first iteration of the loop only, then the remaining lookups are fulfilled from the InetAddress cache (which should have been disabled).

ERROR MESSAGES/STACK TRACES THAT OCCUR :
None; it silently fails to operate in the prescribed manner.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.security.*;

public class bug
  {
    public static void main(String [] args) throws InterruptedException
      {
        Security.setProperty("networkaddress.cache.ttl", "0");
        System.out.println("Cache is confirmed: "
                + Security.getProperty("networkaddress.cache.ttl"));
        for (int i=0; i<25; i++)
          {
            try
              {
                System.out.println(
                        InetAddress.getByName("www.cnn.com").getHostAddress());
              }
            catch (UnknownHostException uhe)
              {
                System.out.println("UHE");
              }
            Thread.sleep(1000);
          }
      }
  }
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
If Win98SE gets the DNS information from a DHCP server, this bug does not seem to occur.  However, this workaround is unacceptable for our applications, which must use Win98SE without DHCP.
###@###.### 2005-03-29 18:28:54 GMT

                                    

Comments
WORK AROUND

Try to run:
    ipconfig /flushdns
to delete the entries in the DNS cache. Then run the java application again. If see DNS activity, one can be sure that it is DNS cache on Windows 98, not jdk's DNS cache, causes the problem.

In such case, decreasing the value of registry key
    HKLM\System\CurrentControlSet\Services\Dnscache\Parameters\MaxCacheEntryTtlLimit
should resolve the problem. The default TTL time is said to be 24-hours.
                                     
2006-03-08
EVALUATION

This issue is mostly likely the DNS cache timeout on Windows 98. The resource documentation should have the registry setting that controls the timeout. As a test the submitter can run with the system property sun.net.spi.nameservice.provider.1 set to "dns,sun". This will cause a name service based on the JNDI-DNS provider to be used. 

Also it is important to point out that setting networkaddress.cache.ttl to 0 could expose the application to a DNS spoofy attach. Please read the warning note in the lib/security/java.security file.
                                     
2005-09-10



Hardware and Software, Engineered to Work Together