Why does getLocalhost () freeze sometimes?
With JRE6 (SUN VM on Windows XP) getLocalhost () sometimes hangs.
Interestingly, if in the debugger in Eclipse it doesn't freeze. I've narrowed it down to a single getLocalhost () call using old-school println. I don't see much that is special in the code I see.
Has anyone else seen this issue?
+1
source to share
2 answers
You didn't specify how long it freezes ... or you meant completely frozen, never returning.
If the local hostname (returned from the JNI call) is not "localhost", the IP address for the localname is resolved using InetAddress.getAddressFromNameService (). This is a DNS call that could block indefinitely the presence and access of the name server.
+1
source to share