From 1818a63c6d492231a95eb8126bbba5abc91205c9 Mon Sep 17 00:00:00 2001 From: Thomas Segismont Date: Wed, 14 Feb 2024 15:38:36 +0100 Subject: [PATCH] Avoid FastThreadLocal in MeterCache (#210) Related to https://github.com/eclipse-vertx/vert.x/issues/5078 FastThreadLocal can cause a memory-leak if not used as a class constant. Signed-off-by: Thomas Segismont --- .../micrometer/impl/AbstractMetrics.java | 76 ++----------- .../io/vertx/micrometer/impl/MeterCache.java | 107 ++++++++++++++---- .../impl/VertxMetricsFactoryImpl.java | 3 +- .../micrometer/impl/VertxMetricsImpl.java | 7 +- 4 files changed, 103 insertions(+), 90 deletions(-) diff --git a/src/main/java/io/vertx/micrometer/impl/AbstractMetrics.java b/src/main/java/io/vertx/micrometer/impl/AbstractMetrics.java index 9aeff307..be823b3a 100644 --- a/src/main/java/io/vertx/micrometer/impl/AbstractMetrics.java +++ b/src/main/java/io/vertx/micrometer/impl/AbstractMetrics.java @@ -29,8 +29,6 @@ import java.util.function.Function; import java.util.function.ToDoubleFunction; -import static io.micrometer.core.instrument.Meter.Type.*; - /** * Abstract class for metrics container. * @@ -40,18 +38,16 @@ public abstract class AbstractMetrics implements MicrometerMetrics { protected final MeterRegistry registry; protected final MetricsNaming names; - protected final String category; - protected final LongGauges longGauges; - protected final EnumSet