From 2bea6ac6ec0b490bdf4f50d73e106d45af4270b1 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Tue, 2 Jan 2024 18:28:35 +0900 Subject: [PATCH] Make lastMeterRolloverStartTime volatile (#4515) See gh-4357 --- .../java/io/micrometer/registry/otlp/OtlpMeterRegistry.java | 2 +- .../io/micrometer/core/instrument/step/StepMeterRegistry.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/implementations/micrometer-registry-otlp/src/main/java/io/micrometer/registry/otlp/OtlpMeterRegistry.java b/implementations/micrometer-registry-otlp/src/main/java/io/micrometer/registry/otlp/OtlpMeterRegistry.java index 3be079089..fe66b92bd 100644 --- a/implementations/micrometer-registry-otlp/src/main/java/io/micrometer/registry/otlp/OtlpMeterRegistry.java +++ b/implementations/micrometer-registry-otlp/src/main/java/io/micrometer/registry/otlp/OtlpMeterRegistry.java @@ -89,7 +89,7 @@ public class OtlpMeterRegistry extends PushMeterRegistry { // Time when the last scheduled rollOver has started. Applicable only for delta // flavour. - private long lastMeterRolloverStartTime = -1; + private volatile long lastMeterRolloverStartTime = -1; @Nullable private ScheduledExecutorService meterPollingService; diff --git a/micrometer-core/src/main/java/io/micrometer/core/instrument/step/StepMeterRegistry.java b/micrometer-core/src/main/java/io/micrometer/core/instrument/step/StepMeterRegistry.java index b9dfbfe77..39642986b 100644 --- a/micrometer-core/src/main/java/io/micrometer/core/instrument/step/StepMeterRegistry.java +++ b/micrometer-core/src/main/java/io/micrometer/core/instrument/step/StepMeterRegistry.java @@ -51,7 +51,7 @@ public abstract class StepMeterRegistry extends PushMeterRegistry { private ScheduledExecutorService meterPollingService; // Time when the last scheduled rollOver has started. - private long lastMeterRolloverStartTime = -1; + private volatile long lastMeterRolloverStartTime = -1; public StepMeterRegistry(StepRegistryConfig config, Clock clock) { super(config, clock);