From 46ec76e551ba3ca8accc7fcf4e60d4d1d50683f8 Mon Sep 17 00:00:00 2001 From: Truc Nguyen <119303279+trnguyencflt@users.noreply.github.com> Date: Wed, 29 May 2024 10:09:28 +0100 Subject: [PATCH] Do not throw ConfigException in case there are different applications configured for the server (#482) * Do not throw ConfigException in case there are different applications configured for the server * Remove unused import --- .../java/io/confluent/rest/ApplicationServer.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/io/confluent/rest/ApplicationServer.java b/core/src/main/java/io/confluent/rest/ApplicationServer.java index be15bb4e69..fd88499c71 100644 --- a/core/src/main/java/io/confluent/rest/ApplicationServer.java +++ b/core/src/main/java/io/confluent/rest/ApplicationServer.java @@ -30,7 +30,6 @@ import java.util.StringTokenizer; import java.util.concurrent.BlockingQueue; import org.apache.kafka.common.MetricName; -import org.apache.kafka.common.config.ConfigException; import org.apache.kafka.common.metrics.Gauge; import org.apache.kafka.common.metrics.Metrics; import org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory; @@ -132,35 +131,31 @@ public List> getApplications() { private void attachMetricsListener(String listenerName, Metrics metrics, Map tags) { - boolean hasNetworkConnector = false; for (NetworkTrafficServerConnector connector : connectors) { if (Objects.equals(connector.getName(), listenerName)) { MetricsListener metricsListener = new MetricsListener(metrics, "jetty", tags); connector.addNetworkTrafficListener(metricsListener); log.info("Registered {} to connector of listener: {}", metricsListener.getClass().getSimpleName(), listenerName); - hasNetworkConnector = true; } } - if (!hasNetworkConnector) { - throw new ConfigException("No network connector found for listener: " + listenerName); + if (connectors.isEmpty()) { + log.warn("No network connector configured for listener: {}", listenerName); } } private void attachNetworkTrafficRateLimitListener(RestConfig appConfig, String listenerName) { if (appConfig.getNetworkTrafficRateLimitEnable()) { - boolean hasNetworkConnector = false; for (NetworkTrafficServerConnector connector : connectors) { if (Objects.equals(connector.getName(), listenerName)) { NetworkTrafficListener rateLimitListener = new RateLimitNetworkTrafficListener(appConfig); connector.addNetworkTrafficListener(rateLimitListener); log.info("Registered {} to connector of listener: {}", rateLimitListener.getClass().getSimpleName(), listenerName); - hasNetworkConnector = true; } } - if (!hasNetworkConnector) { - throw new ConfigException("No network connector found for listener: " + listenerName); + if (connectors.isEmpty()) { + log.warn("No network connector configured for listener: {}", listenerName); } } }