does anyone know what the behavior of the network cache is in java
More specifically, I understand that when you do a dns request , the
succesful result is cached forever by default. If I then make a tcp/ip
request to that host , it will use the cached ip adress to establish
the connection. Suppose the server at this ip adress has been shut
down for maintenance and another server with another ip has been set
in the dns. My tcp/ip connection request will fail. What will happen
in the cache ? Will the dns cached result be invalidated and another
request to the dns will go and find the new ip adress for the host or
am I going to have a problem until I restart the jvm ?
Moving a server to a different address in the manner you've described
does not (automatically) change the address mapping provided by the
DNS server for the domain.
Also, DNS has a "time to live" attribute that tells other DNS servers
how long they should cache entries for the domain, so even updating
the "real" DNS information cannot be assumed to have the desired
effect until at least that much time has passed. In other words, it
takes time for DNS changes to propagate, with the result that even
newly started applications or applications that do no address caching
at all will see the old address for some time after a change.
A running Java application will cache DNS information forever by
default, but by setting properties networkaddress.cache.ttl and/or
networkaddress.cache.negative.ttl you can get different caching
behaviour. These properties are described in the API documentation for
InetAddress, which should have been the first place you looked.
[ don't email me support questions or followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e