nodece commented on code in PR #25851:
URL: https://github.com/apache/pulsar/pull/25851#discussion_r3302917039


##########
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/validator/MultipleListenerValidator.java:
##########
@@ -18,65 +18,174 @@
  */
 package org.apache.pulsar.broker.validator;
 
+import io.netty.util.NetUtil;
 import java.net.URI;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Optional;
 import java.util.Set;
 import java.util.TreeSet;
+import java.util.regex.Pattern;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.pulsar.broker.ServiceConfiguration;
+import org.apache.pulsar.broker.ServiceConfigurationUtils;
 import org.apache.pulsar.policies.data.loadbalancer.AdvertisedListener;
 
 /**
  * Validates multiple listener address configurations.
  */
 public final class MultipleListenerValidator {
 
+    /** Allowed listener-name characters: ASCII letters, digits, underscore, 
hyphen. */
+    private static final Pattern LISTENER_NAME_PATTERN = 
Pattern.compile("[A-Za-z0-9_-]+");
+
     /**
-     * Validate the configuration of `advertisedListeners`, 
`internalListenerName`.
-     * 1. `advertisedListeners` consists of a comma-separated list of 
endpoints.
-     * 2. Each endpoint consists of a listener name and an associated address 
(`listener:scheme://host:port`).
-     * 3. A listener name may be repeated to define both a non-TLS and a TLS 
endpoint.
-     * 4. Duplicate definitions are disallowed.
-     * 5. If `internalListenerName` is absent, set it to the first listener 
defined in `advertisedListeners`.
-     * @param config the pulsar broker configure.
-     * @return
+     * Format the host:port part of a URI for use as a uniqueness key and in 
error messages, wrapping
+     * IPv6 literals in brackets so that the colon separator is unambiguous. 
{@link URI#getHost()} may
+     * or may not include the brackets depending on the JDK, so they are 
stripped before the
+     * {@link NetUtil#isValidIpV6Address} check.
      */
-    public static Map<String, AdvertisedListener> 
validateAndAnalysisAdvertisedListener(ServiceConfiguration config) {
+    static String formatHostPort(URI uri) {
+        String host = uri.getHost();
+        if (host == null) {
+            return host + ":" + uri.getPort();

Review Comment:
   ```suggestion
               throw new IllegalArgumentException("host must not be null")
   ```



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