From d8b95400b3db0408eacf62df049bf06209a70dcb Mon Sep 17 00:00:00 2001 From: Mickael Maison Date: Mon, 4 Nov 2024 12:13:04 +0100 Subject: [PATCH] Bind HTTP server to all interfaces if listener host is empty (#59) 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; }