views:

56

answers:

3

I am working on an eclipse app that has got multiple views. From these views I have to access some data over the wire. An error is thrown in following scenario.

Step 1: Start app, everything works fine.
Step 2: Disable network
Step 3: Enable Network
Step 4: Try to access data over wire from one of the views. The app apparently hangs.
Step 5: Now if you try to access data from some other view, everything works.

Initially I thought that it is happening due to DNS caching by JVM. So I did something like this.

System.setProperty( "networkaddress.cache.ttl", "0" );
System.setProperty( "networkaddress.cache.negative.ttl" , "0" );

But the problem is still there. Any help is appreciated.

+1  A: 

Completely Wild Guess: if you're using TCP your app may not be noticing that its socket has been disconnected. If it's blocked in a read it may not notice until it tries to write something to the socket. It depends on how "clean" the socket shutdown is--if the socket doesn't get a RST packet from the other side it won't know that the other end has gone away.

You could try coercing a thread dump out of your app. Typically the JVM will respond to either Ctrl-\ when running at a terminal or to a kill -QUIT signal with a stack trace of every thread. That'd let you see where the thread in question is blocked.

If you can post some suspect code it'd be much easier to try to make a diagnosis. Or can you explain why you think DNS caching would be an issue?

John Kugelman
A: 

it's probably between step 2 and 3. What type of exception is thrown?

evilReiko
No exception.. Nothing. It just hangs.
Duleb
A: 

Another option to see the current stack when your app is hanging would be to use jps/jstack (bundled with Sun JDKs beginning with 1.5) or visualvm (available in 1.6 SDKs and separately from https://visualvm.dev.java.net/)

jps lists all current java processes on a machine. you can then call jstack with each of these process ids to get the current stack.

Maybe if you could post such a stack trace we could help.

Dominik Mähl