Java

Java caches DNS forever! gosh!

Can you believe it?

Java, by default, indefinitely caches the results of DNS resolutions?

The client side will have to be restarted to pick up the new IP address.

To workaround this, the Sun JDK 1.3 has this system properties callled "sun.net.inetaddr.ttl=0" that disables the caching. more at the jZone

I wonder if this is an issue by design or if the dudes just forgot to implement something? I mean a TTL of 30 minutes or so would be appropriate to configure, or?

Average rating
(0 votes)

Comments

Java caches DNS forever! gosh!

It may be better to put the value to something other than 0, 0 will mean it will lookup every single DNS query. Using this value you can assign a timeout value that would make sense for your application. The value is in seconds.

If you use a DNS based failover system then set it to 2 or 3 seconds, if your DNS results are fairly static make it cache for 20 minutes or so.

This way your code will make your sysadmins happy too :)

Similar entries

  • ONJava.com has the next part 4 of "Java vs. .NET Security" for User Authentication and Authorization up. The article compares the issues and techniques you can utilize in the respective technology. I like this article series….

  • Denis Piliptchouk provides a side-by-side technical comparison of security features of Java v1.4.2/J2EE v1.4 (beta2) and .NET v1.1 platforms in ONJava.com: Java vs. .NET Security, Part 1 – the first part considers Security Configuration and Code Containment – Cryptography and…

  • That sounds nice: the JBoss 4.0 DR 2 from the JBoss 4.0.x Development Releases that was released today aswell a few minutes later features a JBoss JDO implementation for standard Java object persistence a JMS rewrite of the Message service…

  • Microsoft Google Merger

  • BEA, IBM team on new Java specs and hope to provide more consistency across their application servers with three new specifications – most important the Service Data Objects (SDO) aiming to provide a simple, unified programming model for data access…