Solved

DNS oddity

Posted on 2006-06-28
1
213 Views
Last Modified: 2010-03-31
Given the following code:

    ...
    InetSocketAddress isaCurrent = new InetSocketAddress("messenger.hotmail.com", 1863);
    sm_logger.info("Connecting to server '" + isaCurrent + "'.");
    ...

at the tail end of a process that had been running for upwards of a week this code resulted in the following log4j output:
   
    2006-06-21 23:34:50,797 INFO - Connecting to server 'messenger.hotmail.com/65.54.239.140:1863'.

30 seconds later after the process had been stopped and re-started the following lof4j ouput resulted:

    2006-06-21 23:35:28,250 INFO - Connecting to server 'messenger.hotmail.com/65.54.239.210:1863'.

The obvious difference between the two being that the address of 'messenger.hotmail.com' had changed to 65.54.239.210 from 65.54.239.140.  Assuming that the DNS entry had indeed been changed prior to the first log statement, I'm wondering why it took restarting the process for the address change to be recognized in my Java code?

Is it possible that the JVM caches DNS resolves and uses cached values for as long as the process runs going forward?
0
Comment
Question by:derekl
1 Comment
 
LVL 23

Accepted Solution

by:
Ajay-Singh earned 250 total points
ID: 17004447
yes, you are right. By default, JVM caches successful name lookups forever. However, you can change this by setting the following system property:

networkaddress.cache.ttl

The value -1 (by default) indicates that the lookup would be cached forerver. If this is set is 5, it would cache the successful lookup for 5 secs
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now