Copilot commented on code in PR #24790:
URL: https://github.com/apache/pulsar/pull/24790#discussion_r2384259327


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientImpl.java:
##########
@@ -199,7 +200,7 @@ public PulsarClientImpl(ClientConfigurationData conf, 
EventLoopGroup eventLoopGr
     }
 
     @Builder(builderClassName = "PulsarClientImplBuilder")
-    private PulsarClientImpl(ClientConfigurationData conf, EventLoopGroup 
eventLoopGroup, ConnectionPool connectionPool,
+    public PulsarClientImpl(ClientConfigurationData conf, EventLoopGroup 
eventLoopGroup, ConnectionPool connectionPool,

Review Comment:
   The constructor visibility has changed from private to public without clear 
justification. Consider whether this should remain package-private to maintain 
encapsulation while supporting the builder pattern.
   ```suggestion
       PulsarClientImpl(ClientConfigurationData conf, EventLoopGroup 
eventLoopGroup, ConnectionPool connectionPool,
   ```



##########
pulsar-common/src/main/java/org/apache/pulsar/common/util/netty/DnsResolverUtil.java:
##########
@@ -61,8 +75,15 @@ public class DnsResolverUtil {
                     .map(Integer::decode)
                     .filter(i -> i > 0)
                     .orElseGet(() -> {
-                        if (System.getSecurityManager() == null) {
-                            return JDK_DEFAULT_TTL;
+                        try {
+                            if (System.getSecurityManager() == null) {
+                                return JDK_DEFAULT_TTL;
+                            }
+                        } catch (Throwable t) {
+                            log.warn("Cannot use current logic to resolve JDK 
default DNS TTL settings. Use "
+                                            + "sun.net.inetaddr.ttl and 
sun.net.inetaddr.negative.ttl system "
+                                            + "properties for setting default 
values for DNS TTL settings. {}",
+                                    t.getMessage());

Review Comment:
   Catching `Throwable` is too broad and can mask serious errors like 
`OutOfMemoryError`. Catch specific exceptions like `SecurityException` instead.
   ```suggestion
                           } catch (SecurityException e) {
                               log.warn("Cannot use current logic to resolve 
JDK default DNS TTL settings. Use "
                                               + "sun.net.inetaddr.ttl and 
sun.net.inetaddr.negative.ttl system "
                                               + "properties for setting 
default values for DNS TTL settings. {}",
                                       e.getMessage());
   ```



-- 
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