[java-opensaml] branch main updated: OSJ-462 - Metrics PushResporter cannot be initialized

Codeberg noreply at shibboleth.net
Thu Sep 3 13:30:02 UTC 2026


This is an automated email from the git hooks/post-receive script.

codeberg pushed a commit to branch main
in repository java-opensaml.

View the commit online:
https://codeberg.org/Shibboleth/java-opensaml/commit/081d11fe7faacebdc06c16224fe12322266316fb

The following commit(s) were added to refs/heads/main by this push:
     new 081d11fe7 OSJ-462 - Metrics PushResporter cannot be initialized
081d11fe7 is described below

commit 081d11fe7faacebdc06c16224fe12322266316fb
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Thu Sep 3 09:29:52 2026 -0400

    OSJ-462 - Metrics PushResporter cannot be initialized
    
    https://shibboleth.atlassian.net/browse/OSJ-462
    
    Track shutdown and make stop method re-entrant.
---
 .../opensaml/core/metrics/impl/HTTPReporter.java   | 23 +++++++++++++++++++---
 .../core/metrics/impl/HTTPReporterTest.java        |  9 +++++++++
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/opensaml-core-impl/src/main/java/org/opensaml/core/metrics/impl/HTTPReporter.java b/opensaml-core-impl/src/main/java/org/opensaml/core/metrics/impl/HTTPReporter.java
index 0ed15c3fe..20edcbbfc 100644
--- a/opensaml-core-impl/src/main/java/org/opensaml/core/metrics/impl/HTTPReporter.java
+++ b/opensaml-core-impl/src/main/java/org/opensaml/core/metrics/impl/HTTPReporter.java
@@ -103,6 +103,9 @@ public class HTTPReporter extends ScheduledReporter implements InitializableComp
     /** Whether this component has been initialized. */
     private boolean isInitialized;
 
+    /** Whether this component has been shut down. */
+    private boolean isShutdown;
+    
     /**
      * Constructor.
      *
@@ -231,6 +234,17 @@ public class HTTPReporter extends ScheduledReporter implements InitializableComp
         return isInitialized;
     }
 
+    /**
+     * Returns true iff the {@link #stop()} method has been called.
+     * 
+     * @return shutdown status
+     * 
+     * @since 5.3.0
+     */
+    public boolean isShutdown() {
+        return isShutdown;
+    }
+    
     /** {@inheritDoc} */
     public void initialize() throws ComponentInitializationException {
         if (!isInitialized) {
@@ -252,9 +266,12 @@ public class HTTPReporter extends ScheduledReporter implements InitializableComp
     @Override
     @OnTeardown
     public void stop() {
-        super.stop();
-        httpClient = null;
-        httpClientSecurityParameters = null;
+        if (!isShutdown()) {
+            super.stop();
+            httpClient = null;
+            httpClientSecurityParameters = null;
+            isShutdown = true;
+        }
     }
         
     /** {@inheritDoc} */
diff --git a/opensaml-core-impl/src/test/java/org/opensaml/core/metrics/impl/HTTPReporterTest.java b/opensaml-core-impl/src/test/java/org/opensaml/core/metrics/impl/HTTPReporterTest.java
index a1dcd9bbf..c90b14b60 100644
--- a/opensaml-core-impl/src/test/java/org/opensaml/core/metrics/impl/HTTPReporterTest.java
+++ b/opensaml-core-impl/src/test/java/org/opensaml/core/metrics/impl/HTTPReporterTest.java
@@ -16,6 +16,7 @@ package org.opensaml.core.metrics.impl;
 
 import org.opensaml.core.metrics.MetricsSupport;
 import org.opensaml.core.testing.OpenSAMLInitBaseTestCase;
+import org.testng.Assert;
 import org.testng.annotations.Test;
 
 import net.shibboleth.shared.httpclient.HttpClientBuilder;
@@ -30,10 +31,18 @@ public class HTTPReporterTest extends OpenSAMLInitBaseTestCase {
     public void test() throws Exception {
      
         final HTTPReporter reporter = new HTTPReporter(MetricsSupport.getMetricRegistry(), "test", null);
+        
+        Assert.assertFalse(reporter.isInitialized());
+        
         reporter.setCollectorURL("https://localhost/reporter");
         reporter.setHttpClient(new HttpClientBuilder().buildClient());
         reporter.initialize();
         
+        Assert.assertTrue(reporter.isInitialized());
+        Assert.assertFalse(reporter.isShutdown());
+        
+        reporter.stop();
+        Assert.assertTrue(reporter.isShutdown());
         reporter.stop();
     }
     

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list