You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/12/28 11:24:13 UTC

[GitHub] [pulsar] codelipenghui commented on a change in pull request #13503: [security] Allow Client Builder set Dnslookup params

codelipenghui commented on a change in pull request #13503:
URL: https://github.com/apache/pulsar/pull/13503#discussion_r775858775



##########
File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/ClientBuilderImpl.java
##########
@@ -338,6 +338,21 @@ public ClientBuilder enableTransaction(boolean enableTransaction) {
         return this;
     }
 
+    @Override
+    public ClientBuilder dnsLookupBindAddress(String dnsLookupBindAddress) {

Review comment:
       Can we just use one method  such as `dnsLookupBind(String address, int port)`?

##########
File path: pulsar-client/src/test/java/org/apache/pulsar/client/impl/ClientBuilderImplTest.java
##########
@@ -70,4 +70,10 @@ public String getServiceUrl() {
         }).build();
     }
 
+    @Test(expectedExceptions = IllegalArgumentException.class)
+    public void testClientBuilderWithIllegalPort() throws PulsarClientException {

Review comment:
       Better have a check for the max allowed port number.

##########
File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/ClientBuilderImpl.java
##########
@@ -338,6 +338,21 @@ public ClientBuilder enableTransaction(boolean enableTransaction) {
         return this;
     }
 
+    @Override
+    public ClientBuilder dnsLookupBindAddress(String dnsLookupBindAddress) {
+        conf.setDnsLookupBindAddress(dnsLookupBindAddress);
+        return this;
+    }
+
+    @Override
+    public ClientBuilder dnsLookupBindPort(int dnsLookupBindPort) {
+        if (dnsLookupBindPort < 0 || dnsLookupBindPort > 65535) {
+            throw new IllegalArgumentException("DnsLookBindPort need to be within the range of 0 and 65535");
+        }

Review comment:
       ```suggestion
          checkArgument(dnsLookupBindPort >= 0 && dnsLookupBindPort <= 65535, "DnsLookBindPort need to be within the range of 0 and 65535");
   ```




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org