jianyun8023 commented on code in PR #22329:
URL: https://github.com/apache/pulsar/pull/22329#discussion_r1536634362


##########
pulsar-common/src/main/java/org/apache/pulsar/common/util/netty/DnsResolverUtil.java:
##########
@@ -19,12 +19,19 @@
 package org.apache.pulsar.common.util.netty;
 
 import io.netty.resolver.dns.DnsNameResolverBuilder;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
+import java.security.Security;
+import java.util.Optional;
 import lombok.extern.slf4j.Slf4j;
 
 @Slf4j
 public class DnsResolverUtil {
+
+    private static final String CACHE_POLICY_PROP = "networkaddress.cache.ttl";
+    private static final String CACHE_POLICY_PROP_FALLBACK = 
"sun.net.inetaddr.ttl";
+    private static final String NEGATIVE_CACHE_POLICY_PROP = 
"networkaddress.cache.negative.ttl";
+    private static final String NEGATIVE_CACHE_POLICY_PROP_FALLBACK = 
"sun.net.inetaddr.negative.ttl";
+    /* default value for positive lookups */
+    private static final int JDK_DEFAULT_TTL = 30;

Review Comment:
   After examining the logic of `InetAddressCachePolicy`, I discovered that it 
sets a default TTL within the class. If the `networkaddress.cache.ttl` or 
`sun.net.inetaddr.ttl` parameter is not retrieved, it defaults to a value of 
30. This contradicts their documentation.
   
   ```
       static {
           Integer tmp = getProperty(cachePolicyProp, cachePolicyPropFallback);
           if (tmp != null) {
               cachePolicy = tmp < 0 ? FOREVER : tmp;
               propertySet = true;
           } else {
               /* No properties defined for positive caching. If there is no
                * security manager then use the default positive cache value.
                */
               if (System.getSecurityManager() == null) {
                   cachePolicy = DEFAULT_POSITIVE;
               }
           }
       }
   ```
   
[InetAddressCachePolicy.java#L103C5-L130C6](https://github.com/openjdk/jdk/blob/bc73963974a824d77d54b8b0edbf8f05262b721c/src/java.base/share/classes/sun/net/InetAddressCachePolicy.java#L103C5-L130C6)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to