networkaddress.cache.ttl
Java Security Property accepts an integer value corresponding to the number of seconds to cache The default value of networkaddress.cache.ttl is set to infinite or -1
when a security manager is enabled. When a security manager is not enabled it's default value is JVM implementation specific. In most cases around 30 seconds.
networkaddress.cache.ttl
ExplainedWhen Java resolves a a hostname into an IP address (for example by performing a DNS lookup) it will cache the value for a period of time determined by this setting.
When the value of networkaddress.cache.ttl is -1
it will cache lookups forever (the duration of the JVM process), when set to 0
no caching will be performed on address lookups.
The caching of address lookup failures is controlled by the Java security property networkaddress.cache.negative.ttl
The sun.net.inetaddr.ttl
system property is an implementation specific private system property that corresponds to this Java Security Property.
Here are some other Java properties related to networking:
http.agent
http.keepAlive
http.maxConnections
https.protocols
java.net.preferIPv4Stack
java.net.preferIPv6Addresses
java.net.useSystemProxies
javax.net.debug
javax.net.ssl.trustStore
jdk.net.hosts.file
jdk.tls.client.protocols
jdk.tls.disabledAlgorithms
networkaddress.cache.negative.ttl
sun.net.client.defaultConnectTimeout
sun.net.client.defaultReadTimeout
sun.net.inetaddr.ttl
Java has supported the networkaddress.cache.ttl
security property since at least version 6, support may go back to even older versions of java.
networkaddress.cache.ttl
at RuntimeYou can set networkaddress.cache.ttl at runtime with the following Java code:
java.security.Security.setProperty("networkaddress.cache.ttl", "30");
Please note that the networkaddress.cache.ttl value needs to be specified early, before the internal java classes are loaded that might use this value otherwise it will be ignored.
To read the value of networkaddress.cache.ttl at runtime, you can use this Java code:
String propertyValue = java.security.Security.getProperty("networkaddress.cache.ttl"); if (propertyValue != null) { System.out.println("networkaddress.cache.ttl = " + propertyValue); } else { System.out.println("networkaddress.cache.ttl was null"); }
networkaddress.cache.ttl
on StartupBe aware that networkaddress.cache.ttl
is not a Java System Property, it is a Java Security Property. Therefor you cannot set it from the command line using -Dnetworkaddress.cache.ttl
. You have to set networkaddress.cache.ttl in the java.security
properties file.