From d101ea1b692644c32a849877296d4f93e93ce808 Mon Sep 17 00:00:00 2001 From: Tomas Langer Date: Mon, 9 Nov 2020 20:38:40 +0100 Subject: [PATCH 1/3] Upgrade GraalVM. Signed-off-by: Tomas Langer --- dependencies/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies/pom.xml b/dependencies/pom.xml index 901430700c9..4f209722894 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 From 0c8c6b11317c646c663d4ab3eceb35d1865e771c Mon Sep 17 00:00:00 2001 From: Tomas Langer Date: Mon, 9 Nov 2020 20:39:14 +0100 Subject: [PATCH 2/3] Fixes for native image. Signed-off-by: Tomas Langer --- .../microprofile/metrics/MetricsCdiExtension.java | 11 +++++++++-- .../microprofile/metrics/RegistryProducer.java | 12 +++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) 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 af57fc97421..b05fa7c3f7b 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.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; @@ -137,6 +138,7 @@ 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 Set syntheticSimplyTimersToRegister = new HashSet<>(); @SuppressWarnings("unchecked") private static T getReference(BeanManager bm, Type type, Bean bean) { @@ -634,7 +636,7 @@ private void registerProduce 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)) { @@ -643,7 +645,12 @@ private void registerSyntheticSimpleTimerMetric(@Observes ProcessManagedBean LOGGER.log(Level.FINE, () -> "Processing synthetic SimplyTimed annotations for " + clazz.getName()); - methodsWithSyntheticSimplyTimer.get(clazz).forEach(MetricsCdiExtension::syntheticSimpleTimer); + syntheticSimplyTimersToRegister.addAll(methodsWithSyntheticSimplyTimer.get(clazz)); + } + + private void registerSyntheticSimpleTimerMetrics(@Observes @RuntimeStart Object event) { + syntheticSimplyTimersToRegister.forEach(MetricsCdiExtension::syntheticSimpleTimer); + syntheticSimplyTimersToRegister.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 b9984840ce6..275329a218e 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 @@ 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 @@ @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 @@ public static org.eclipse.microprofile.metrics.MetricRegistry getDefaultRegistry @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); } /** From 7460c2ba1628fa488c56a86ebd89d96b5f7b152f Mon Sep 17 00:00:00 2001 From: Tomas Langer Date: Mon, 9 Nov 2020 20:50:18 +0100 Subject: [PATCH 3/3] Typo fix. Signed-off-by: Tomas Langer --- .../metrics/MetricsCdiExtension.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 b05fa7c3f7b..cd48d751a21 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 @@ -137,8 +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 Set syntheticSimplyTimersToRegister = new HashSet<>(); + 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) { @@ -323,7 +323,7 @@ private void clearAnnotationInfo(@Observes AfterDeploymentValidation adv) { } metricsAnnotatedClasses.clear(); metricsAnnotatedClassesProcessed.clear(); - methodsWithSyntheticSimplyTimer.clear(); + methodsWithSyntheticSimpleTimer.clear(); } /** @@ -495,7 +495,7 @@ private void recordSimplyTimedForRestResources(@Observes } })); if (!methodsToRecord.isEmpty()) { - methodsWithSyntheticSimplyTimer.put(clazz, methodsToRecord); + methodsWithSyntheticSimpleTimer.put(clazz, methodsToRecord); } } @@ -639,18 +639,18 @@ private void registerProduce 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()); - syntheticSimplyTimersToRegister.addAll(methodsWithSyntheticSimplyTimer.get(clazz)); + syntheticSimpleTimersToRegister.addAll(methodsWithSyntheticSimpleTimer.get(clazz)); } private void registerSyntheticSimpleTimerMetrics(@Observes @RuntimeStart Object event) { - syntheticSimplyTimersToRegister.forEach(MetricsCdiExtension::syntheticSimpleTimer); - syntheticSimplyTimersToRegister.clear(); + syntheticSimpleTimersToRegister.forEach(MetricsCdiExtension::syntheticSimpleTimer); + syntheticSimpleTimersToRegister.clear(); } static boolean restEndpointsMetricEnabledFromConfig() {