From 61a7756bdd13c11fc2fca18008bce9beed0bd084 Mon Sep 17 00:00:00 2001 From: Ladislav Thon Date: Thu, 14 Nov 2024 13:23:41 +0100 Subject: [PATCH] fix dynamic lookup in CompoundMetricsProvider --- .../faulttolerance/metrics/CompoundMetricsProvider.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/implementation/fault-tolerance/src/main/java/io/smallrye/faulttolerance/metrics/CompoundMetricsProvider.java b/implementation/fault-tolerance/src/main/java/io/smallrye/faulttolerance/metrics/CompoundMetricsProvider.java index cd90aa44..56e05c0f 100644 --- a/implementation/fault-tolerance/src/main/java/io/smallrye/faulttolerance/metrics/CompoundMetricsProvider.java +++ b/implementation/fault-tolerance/src/main/java/io/smallrye/faulttolerance/metrics/CompoundMetricsProvider.java @@ -9,7 +9,7 @@ import jakarta.annotation.Priority; import jakarta.enterprise.inject.Alternative; -import jakarta.enterprise.inject.spi.CDI; +import jakarta.enterprise.inject.Instance; import jakarta.inject.Inject; import jakarta.inject.Singleton; @@ -32,15 +32,15 @@ public class CompoundMetricsProvider implements MetricsProvider { @Inject CompoundMetricsProvider( + Instance lookup, @ConfigProperty(name = "MP_Fault_Tolerance_Metrics_Enabled", defaultValue = "true") boolean metricsEnabled) { - CDI cdi = CDI.current(); List> allProviders = List.of(MicroProfileMetricsProvider.class, OpenTelemetryProvider.class, MicrometerProvider.class); List providers = new ArrayList<>(); for (Class clazz : allProviders) { try { - providers.add(cdi.select(clazz).get()); + providers.add(lookup.select(clazz).get()); } catch (Exception ignored) { // either the bean does not exist, or some of its dependencies does not exist }