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/02/07 19:11:34 UTC

[GitHub] [pulsar] gaoran10 commented on a change in pull request #9517: Add listeningInterface in broker.conf,Use Network Interface instead of IP

gaoran10 commented on a change in pull request #9517:
URL: https://github.com/apache/pulsar/pull/9517#discussion_r571672621



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java
##########
@@ -1224,7 +1226,23 @@ public ShutdownService getShutdownService() {
      * @return Hostname or IP address the service advertises to the outside world.
      */
     public static String advertisedAddress(ServiceConfiguration config) {
-        return ServiceConfigurationUtils.getDefaultOrConfiguredAddress(config.getAdvertisedAddress());
+        String advertisedAddress = null;
+        if (!isBlank(config.getAdvertisedAddress())) {
+            advertisedAddress = config.getAdvertisedAddress();
+        } else {
+            String iface = config.getListeningInterface();
+            if (!isBlank(iface)) {
+                try {
+                    advertisedAddress = DNS.getDefaultIP(iface);
+                } catch (UnknownHostException e) {
+                    LOG.error("GetAdvertisedAddressIP Fail: {}", iface);

Review comment:
       Do we need to throw an exception or use a default value if the error occurs?




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

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