From ccbb643f846aac4ea3e3647448bb1113cf44d6ce Mon Sep 17 00:00:00 2001 From: Jeoffrey Haeyaert Date: Mon, 6 Mar 2023 19:00:27 +0100 Subject: [PATCH] fix: avoid spring loading issue with vertx and k8s client --- .../io/gravitee/node/vertx/VertxFactory.java | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/gravitee-node-vertx/src/main/java/io/gravitee/node/vertx/VertxFactory.java b/gravitee-node-vertx/src/main/java/io/gravitee/node/vertx/VertxFactory.java index 95b59e50f..ede1ab023 100644 --- a/gravitee-node-vertx/src/main/java/io/gravitee/node/vertx/VertxFactory.java +++ b/gravitee-node-vertx/src/main/java/io/gravitee/node/vertx/VertxFactory.java @@ -42,6 +42,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.Environment; @@ -210,21 +211,22 @@ private void loadMetricLabels() { } private Map> readConfiguredLabelsByCategory(final String type) { - return Arrays - .stream(MetricsDomain.values()) - .map(MetricsDomain::toCategory) - .flatMap(category -> - EnvironmentUtils - .getPropertiesStartingWith((ConfigurableEnvironment) environment, "services.metrics." + type + "." + category) - .entrySet() - .stream() - ) - .collect( - Collectors.groupingBy( - e -> e.getKey().replaceAll("^services\\.metrics\\." + type + "\\." + "(.*)\\[\\d+]$", "$1"), - Collectors.mapping(e -> toLabel((String) e.getValue()), Collectors.>toCollection(HashSet::new)) - ) - ); + final Map> labelsByCategory = new HashMap<>(); + + for (MetricsDomain metricsDomain : MetricsDomain.values()) { + final String category = metricsDomain.toCategory(); + final Set