This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch 3.7.x
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/3.7.x by this push:
     new 4bb1e9b382 [FIX] Unregister gauge upon shutdown (#1251)
4bb1e9b382 is described below

commit 4bb1e9b3827cc779fc61584ea80e09e8e990e71f
Author: Benoit TELLIER <btell...@linagora.com>
AuthorDate: Fri Oct 14 10:43:59 2022 +0700

    [FIX] Unregister gauge upon shutdown (#1251)
    
    Otherwise measurements are still performed despite underlying components
    being stopped.
---
 .../apache/james/metrics/dropwizard/DropWizardGaugeRegistry.java    | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git 
a/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardGaugeRegistry.java
 
b/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardGaugeRegistry.java
index eaf944e740..f79e2832ee 100644
--- 
a/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardGaugeRegistry.java
+++ 
b/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardGaugeRegistry.java
@@ -19,6 +19,7 @@
 
 package org.apache.james.metrics.dropwizard;
 
+import javax.annotation.PreDestroy;
 import javax.inject.Inject;
 
 import org.apache.james.metrics.api.Gauge;
@@ -39,4 +40,9 @@ public class DropWizardGaugeRegistry implements GaugeRegistry 
{
         metricRegistry.gauge(name, () -> gauge::get);
         return this;
     }
+
+    @PreDestroy
+    public void shutDown() {
+        metricRegistry.getGauges().keySet().forEach(metricRegistry::remove);
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org
For additional commands, e-mail: notifications-h...@james.apache.org

Reply via email to