You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ch...@apache.org on 2021/04/25 13:30:32 UTC

[kafka] branch 2.8 updated: KAFKA-12702: Fix NPE in networkListeners from BrokerServer in 2.8 (#10586)

This is an automated email from the ASF dual-hosted git repository.

chia7712 pushed a commit to branch 2.8
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/2.8 by this push:
     new 35d47f4  KAFKA-12702: Fix NPE in networkListeners from BrokerServer in 2.8 (#10586)
35d47f4 is described below

commit 35d47f488b63941ac15dd3159005d6f40da6ef18
Author: wenbingshen <ol...@gmail.com>
AuthorDate: Sun Apr 25 21:29:29 2021 +0800

    KAFKA-12702: Fix NPE in networkListeners from BrokerServer in 2.8 (#10586)
    
    Reviewers: Chia-Ping Tsai <ch...@gmail.com>
---
 core/src/main/scala/kafka/server/BrokerServer.scala | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/core/src/main/scala/kafka/server/BrokerServer.scala b/core/src/main/scala/kafka/server/BrokerServer.scala
index b02659c..d0f9e67 100644
--- a/core/src/main/scala/kafka/server/BrokerServer.scala
+++ b/core/src/main/scala/kafka/server/BrokerServer.scala
@@ -21,6 +21,7 @@ import java.util
 import java.util.concurrent.{CompletableFuture, TimeUnit, TimeoutException}
 import java.util.concurrent.atomic.AtomicBoolean
 import java.util.concurrent.locks.ReentrantLock
+import java.net.InetAddress
 
 import kafka.cluster.Broker.ServerInfo
 import kafka.coordinator.group.GroupCoordinator
@@ -272,7 +273,7 @@ class BrokerServer(
       val networkListeners = new ListenerCollection()
       config.advertisedListeners.foreach { ep =>
         networkListeners.add(new Listener().
-          setHost(ep.host).
+          setHost(if (ep.host == null || ep.host.trim.isEmpty) InetAddress.getLocalHost.getCanonicalHostName else ep.host).
           setName(ep.listenerName.value()).
           setPort(socketServer.boundPort(ep.listenerName)).
           setSecurityProtocol(ep.securityProtocol.id))