From ac8a3ebb0cb4aa604452db1568ee2df477a00ac3 Mon Sep 17 00:00:00 2001 From: Tomas Langer Date: Tue, 10 Nov 2020 00:05:26 +0100 Subject: [PATCH] Upgrage GraalVM (#2510) * Upgrade GraalVM. Signed-off-by: Tomas Langer --- dependencies/pom.xml | 2 +- .../metrics/MetricsCdiExtension.java | 19 +++++++++++++------ .../metrics/RegistryProducer.java | 12 +++++++----- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/dependencies/pom.xml b/dependencies/pom.xml index 901430700..4f2097228 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -51,7 +51,7 @@ 2.3.1 1.30.11 2.3.3 - 20.1.0 + 20.2.0 1.32.1 28.1-jre 1.4.199 diff --git a/microprofile/metrics/src/main/java/io/helidon/microprofile/metrics/MetricsCdiExtension.java b/microprofile/metrics/src/main/java/io/helidon/microprofile/metrics/MetricsCdiExtension.java index af57fc974..cd48d751a 100644 --- a/microprofile/metrics/src/main/java/io/helidon/microprofile/metrics/MetricsCdiExtension.java +++ b/microprofile/metrics/src/main/java/io/helidon/microprofile/metrics/MetricsCdiExtension.java @@ -73,6 +73,7 @@ import io.helidon.common.Errors; import io.helidon.config.Config; import io.helidon.config.ConfigValue; import io.helidon.metrics.MetricsSupport; +import io.helidon.microprofile.cdi.RuntimeStart; import io.helidon.microprofile.server.ServerCdiExtension; import io.helidon.webserver.Routing; @@ -136,7 +137,8 @@ public class MetricsCdiExtension implements Extension { private final Set> metricsAnnotatedClasses = new HashSet<>(); private final Set> metricsAnnotatedClassesProcessed = new HashSet<>(); - private final Map, Set> methodsWithSyntheticSimplyTimer = new HashMap<>(); + private final Map, Set> methodsWithSyntheticSimpleTimer = new HashMap<>(); + private final Set syntheticSimpleTimersToRegister = new HashSet<>(); @SuppressWarnings("unchecked") private static T getReference(BeanManager bm, Type type, Bean bean) { @@ -321,7 +323,7 @@ public class MetricsCdiExtension implements Extension { } metricsAnnotatedClasses.clear(); metricsAnnotatedClassesProcessed.clear(); - methodsWithSyntheticSimplyTimer.clear(); + methodsWithSyntheticSimpleTimer.clear(); } /** @@ -493,7 +495,7 @@ public class MetricsCdiExtension implements Extension { } })); if (!methodsToRecord.isEmpty()) { - methodsWithSyntheticSimplyTimer.put(clazz, methodsToRecord); + methodsWithSyntheticSimpleTimer.put(clazz, methodsToRecord); } } @@ -634,16 +636,21 @@ public class MetricsCdiExtension implements Extension { producers.clear(); } - private void registerSyntheticSimpleTimerMetric(@Observes ProcessManagedBean pmb) { + private void collectSyntheticSimpleTimerMetric(@Observes ProcessManagedBean pmb) { AnnotatedType type = pmb.getAnnotatedBeanClass(); Class clazz = type.getJavaClass(); - if (!methodsWithSyntheticSimplyTimer.containsKey(clazz)) { + if (!methodsWithSyntheticSimpleTimer.containsKey(clazz)) { return; } LOGGER.log(Level.FINE, () -> "Processing synthetic SimplyTimed annotations for " + clazz.getName()); - methodsWithSyntheticSimplyTimer.get(clazz).forEach(MetricsCdiExtension::syntheticSimpleTimer); + syntheticSimpleTimersToRegister.addAll(methodsWithSyntheticSimpleTimer.get(clazz)); + } + + private void registerSyntheticSimpleTimerMetrics(@Observes @RuntimeStart Object event) { + syntheticSimpleTimersToRegister.forEach(MetricsCdiExtension::syntheticSimpleTimer); + syntheticSimpleTimersToRegister.clear(); } static boolean restEndpointsMetricEnabledFromConfig() { diff --git a/microprofile/metrics/src/main/java/io/helidon/microprofile/metrics/RegistryProducer.java b/microprofile/metrics/src/main/java/io/helidon/microprofile/metrics/RegistryProducer.java index b9984840c..275329a21 100644 --- a/microprofile/metrics/src/main/java/io/helidon/microprofile/metrics/RegistryProducer.java +++ b/microprofile/metrics/src/main/java/io/helidon/microprofile/metrics/RegistryProducer.java @@ -19,6 +19,9 @@ package io.helidon.microprofile.metrics; import javax.enterprise.context.ApplicationScoped; import javax.enterprise.inject.Produces; +import io.helidon.common.LazyValue; +import io.helidon.metrics.RegistryFactory; + import org.eclipse.microprofile.metrics.MetricRegistry; import org.eclipse.microprofile.metrics.MetricRegistry.Type; import org.eclipse.microprofile.metrics.annotation.RegistryType; @@ -29,8 +32,7 @@ import org.eclipse.microprofile.metrics.annotation.RegistryType; @ApplicationScoped final class RegistryProducer { - private static final io.helidon.metrics.RegistryFactory REGISTRY_FACTORY = - io.helidon.metrics.RegistryFactory.getInstance(); + private static final LazyValue REGISTRY_FACTORY = LazyValue.create(RegistryFactory::getInstance); private RegistryProducer() { } @@ -43,19 +45,19 @@ final class RegistryProducer { @Produces @RegistryType(type = Type.APPLICATION) public static org.eclipse.microprofile.metrics.MetricRegistry getApplicationRegistry() { - return REGISTRY_FACTORY.getRegistry(Type.APPLICATION); + return REGISTRY_FACTORY.get().getRegistry(Type.APPLICATION); } @Produces @RegistryType(type = Type.BASE) public static org.eclipse.microprofile.metrics.MetricRegistry getBaseRegistry() { - return REGISTRY_FACTORY.getRegistry(Type.BASE); + return REGISTRY_FACTORY.get().getRegistry(Type.BASE); } @Produces @RegistryType(type = Type.VENDOR) public static org.eclipse.microprofile.metrics.MetricRegistry getVendorRegistry() { - return REGISTRY_FACTORY.getRegistry(Type.VENDOR); + return REGISTRY_FACTORY.get().getRegistry(Type.VENDOR); } /**