How to configure Java DNS TTL result cache in Web Start application?

I can say that the DNS resolver DNS is not cached as follows:

java.security.Security.setProperty("networkaddress.cache.ttl", "0");

This works great when the program starts directly from the JRE, however when starting from Web Start this parameter is ignored and it is cached forever. I do not get SecurityException.

However, if I set the security manager to null, the parameter will work in Web Start:

System.setSecurityManager(null);

Does anyone know a way to enable this property in Web Start without disabling the security manager? Also, if you can just shed more light on what is happening, I would appreciate it.

+3
source share
2 answers

, sun.net.InetAddressCachePolicy {} . , Webstart , .

, , InetAddressCachePolicy.setIfNotSet(InetAddressCachePolicy.NEVER).

jnlp: < name= "com.sun.net.inetaddr.ttl" value = "0" /" >

webstart ( ), Field f= InetAddressCachePolicy.getDeclaredField("cachePolicy"); f.setAccessible(true); f.setInt(0);, .

!

+2

javaws? ,

javaws -J-Dnetworkaddress.cache.ttl=0 yourapp.jnlp
+1

All Articles