GERONIMO-6681 prevent failure from a failing register in extensions master
authorRomain Manni-Bucau <rmannibucau@gmail.com>
Thu, 10 Jan 2019 08:09:15 +0000 (09:09 +0100)
committerRomain Manni-Bucau <rmannibucau@gmail.com>
Thu, 10 Jan 2019 08:09:15 +0000 (09:09 +0100)
geronimo-metrics-extensions/geronimo-metrics-extension-common/src/main/java/org/apache/geronimo/microprofile/metrics/extension/common/MicroprofileMetricsAdapter.java

index 986aa7a..9dbbb64 100644 (file)
@@ -19,6 +19,7 @@ package org.apache.geronimo.microprofile.metrics.extension.common;
 import static org.eclipse.microprofile.metrics.MetricType.GAUGE;
 
 import java.util.function.Consumer;
+import java.util.logging.Logger;
 
 import org.eclipse.microprofile.metrics.Gauge;
 import org.eclipse.microprofile.metrics.Metadata;
@@ -36,8 +37,12 @@ public class MicroprofileMetricsAdapter {
             final Metadata metadata = new Metadata(def.getName(), def.getDisplayName(), def.getDescription(), GAUGE,
                     def.getUnit());
             metadata.setReusable(true);
-            registry.register(metadata,
-                    (Gauge<Double>) () -> def.getEvaluator().getAsDouble());
+            try {
+                registry.register(metadata, (Gauge<Double>) () -> def.getEvaluator()
+                                                                     .getAsDouble());
+            } catch (final RuntimeException re) {
+                Logger.getLogger(MicroprofileMetricsAdapter.class.getName()).fine(re.getMessage());
+            }
         };
     }