From bd11979a17e9f6650794846ca65db2671011304f Mon Sep 17 00:00:00 2001 From: Mickael Maison Date: Mon, 4 Nov 2024 11:09:56 +0100 Subject: [PATCH] Bind HTTP server to all interfaces if listener host is empty Signed-off-by: Mickael Maison --- .../io/strimzi/kafka/metrics/http/HttpServers.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/strimzi/kafka/metrics/http/HttpServers.java b/src/main/java/io/strimzi/kafka/metrics/http/HttpServers.java index 49ec769..6672928 100644 --- a/src/main/java/io/strimzi/kafka/metrics/http/HttpServers.java +++ b/src/main/java/io/strimzi/kafka/metrics/http/HttpServers.java @@ -60,11 +60,13 @@ public static class ServerCounter { private ServerCounter(Listener listener, PrometheusRegistry registry) throws IOException { this.count = new AtomicInteger(); - this.server = HTTPServer.builder() - .hostname(listener.host) + HTTPServer.Builder builder = HTTPServer.builder() .port(listener.port) - .registry(registry) - .buildAndStart(); + .registry(registry); + if (!listener.host.isEmpty()) { + builder.hostname(listener.host); + } + this.server = builder.buildAndStart(); LOG.debug("Started HTTP server on http://{}:{}", listener.host, server.getPort()); this.listener = listener; }