Solved

DNS oddity

Posted on 2006-06-28
1
215 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
mockito example issue 8 72
hibernate example for saving data 19 38
How to execute a Python program and gather return output in Java 2 29
null output 3 25
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

776 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