From 12f7f63034a7d07feb0115f089a99cb30281385b Mon Sep 17 00:00:00 2001 From: Luke Chen Date: Mon, 31 Jul 2023 19:47:45 +0800 Subject: [PATCH] ZOOKEEPER-4728: force to re-resolve hostname into IP when binding --- .../main/java/org/apache/zookeeper/server/quorum/Leader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/Leader.java b/zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/Leader.java index bff1e4b6954..20d2227547c 100644 --- a/zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/Leader.java +++ b/zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/Leader.java @@ -318,7 +318,7 @@ Optional createServerSocket(InetSocketAddress address, boolean por serverSocket = new ServerSocket(); } serverSocket.setReuseAddress(true); - serverSocket.bind(address); + serverSocket.bind(new InetSocketAddress(address.getHostString(), address.getPort())); return Optional.of(serverSocket); } catch (IOException e) { LOG.error("Couldn't bind to {}", address.toString(), e);