[java-opensaml] branch main updated: JSSH-71 Remove the impact of the DestructableComponent Interface

Codeberg noreply at shibboleth.net
Mon Jul 20 15:28:16 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/dd75177b6740c30fff1debe1088e97980d44e0c3

The following commit(s) were added to refs/heads/main by this push:
     new dd75177b6 JSSH-71 Remove the impact of the DestructableComponent Interface
dd75177b6 is described below

commit dd75177b6740c30fff1debe1088e97980d44e0c3
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Mon Jul 20 16:27:53 2026 +0100

    JSSH-71 Remove the impact of the DestructableComponent Interface
    
    https://shibboleth.atlassian.net/browse/JSSH-71
    
    Complete the transition to using annotation-led teardown.
    
    Stop using destroy in tests and use the annotation if it seems
    important.
    
    Remove a couple of already dubious calls to destroy in EncodeMessage
    and DecodeMessage
---
 .../main/java/org/opensaml/profile/action/impl/DecodeMessage.java  | 3 ---
 .../main/java/org/opensaml/profile/action/impl/EncodeMessage.java  | 3 ---
 .../binding/security/impl/MessageReplaySecurityHandlerTest.java    | 4 ++--
 .../common/profile/logic/tests/EntityGroupNamePredicateTest.java   | 4 ++--
 .../resolver/impl/AbstractDynamicHTTPMetadataResolverTest.java     | 5 ++---
 .../resolver/impl/AbstractDynamicMetadataResolverTest.java         | 5 ++---
 .../impl/FunctionDrivenDynamicHTTPMetadataResolverTest.java        | 5 ++---
 .../metadata/resolver/impl/LocalDynamicMetadataResolverTest.java   | 7 +++----
 .../saml2/assertion/impl/OneTimeUseConditionValidatorTest.java     | 5 +++--
 .../opensaml/saml/saml2/profile/impl/AddNameIDToSubjectsTest.java  | 3 ++-
 .../java/org/opensaml/storage/impl/MemoryStorageServiceTest.java   | 1 -
 .../org/opensaml/storage/impl/StorageServiceReplayCacheTest.java   | 6 ++++--
 .../opensaml/storage/impl/StorageServiceRevocationCacheTest.java   | 4 ++--
 .../main/java/org/opensaml/storage/testing/StorageServiceTest.java | 5 ++---
 14 files changed, 26 insertions(+), 34 deletions(-)

diff --git a/opensaml-profile-impl/src/main/java/org/opensaml/profile/action/impl/DecodeMessage.java b/opensaml-profile-impl/src/main/java/org/opensaml/profile/action/impl/DecodeMessage.java
index 31ded7639..d8261a48d 100644
--- a/opensaml-profile-impl/src/main/java/org/opensaml/profile/action/impl/DecodeMessage.java
+++ b/opensaml-profile-impl/src/main/java/org/opensaml/profile/action/impl/DecodeMessage.java
@@ -96,9 +96,6 @@ public class DecodeMessage extends AbstractProfileAction {
         } catch (final MessageDecodingException e) {
             log.error("{} Unable to decode incoming request", getLogPrefix(), e);
             ActionSupport.buildEvent(profileRequestContext, EventIds.UNABLE_TO_DECODE);
-        } finally {
-            // TODO: should we actually destroy the MessageDecoder here?
-            decoder.destroy();
         }
     }
     
diff --git a/opensaml-profile-impl/src/main/java/org/opensaml/profile/action/impl/EncodeMessage.java b/opensaml-profile-impl/src/main/java/org/opensaml/profile/action/impl/EncodeMessage.java
index 030d8a605..fef00d77c 100644
--- a/opensaml-profile-impl/src/main/java/org/opensaml/profile/action/impl/EncodeMessage.java
+++ b/opensaml-profile-impl/src/main/java/org/opensaml/profile/action/impl/EncodeMessage.java
@@ -165,9 +165,6 @@ public class EncodeMessage extends AbstractProfileAction {
         } catch (final MessageEncodingException | ComponentInitializationException | MessageHandlerException e) {
             log.error("{} Unable to encode outbound response", getLogPrefix(), e);
             ActionSupport.buildEvent(profileRequestContext, EventIds.UNABLE_TO_ENCODE);
-        } finally {
-            // TODO: do we want to destroy the encoder here?
-            encoder.destroy();
         }
     }
     
diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/common/binding/security/impl/MessageReplaySecurityHandlerTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/common/binding/security/impl/MessageReplaySecurityHandlerTest.java
index c7905e9d7..aa417af5e 100644
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/common/binding/security/impl/MessageReplaySecurityHandlerTest.java
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/common/binding/security/impl/MessageReplaySecurityHandlerTest.java
@@ -28,6 +28,7 @@ import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import net.shibboleth.shared.component.ComponentInitializationException;
+import net.shibboleth.shared.primitive.AnnotationsSupport;
 
 /**
  * Testing SAML message replay security policy rule.
@@ -71,10 +72,9 @@ public class MessageReplaySecurityHandlerTest extends XMLObjectBaseTestCase {
     protected void tearDown() {
         handler = null;
         
-        replayCache.destroy();
         replayCache = null;
         
-        storageService.destroy();
+        AnnotationsSupport.callOnTeardownAnnotations(storageService);
         storageService = null;
     }
     
diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/common/profile/logic/tests/EntityGroupNamePredicateTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/common/profile/logic/tests/EntityGroupNamePredicateTest.java
index 364d1e0b0..780393e5b 100644
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/common/profile/logic/tests/EntityGroupNamePredicateTest.java
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/common/profile/logic/tests/EntityGroupNamePredicateTest.java
@@ -15,6 +15,7 @@
 package org.opensaml.saml.common.profile.logic.tests;
 
 import net.shibboleth.shared.collection.CollectionSupport;
+import net.shibboleth.shared.primitive.AnnotationsSupport;
 import net.shibboleth.shared.resolver.CriteriaSet;
 import net.shibboleth.shared.spring.resource.ResourceHelper;
 
@@ -61,8 +62,7 @@ public class EntityGroupNamePredicateTest extends XMLObjectBaseTestCase {
     
     @AfterClass
     protected void tearDown() {
-        metadataProvider.destroy();
-        filter.destroy();
+        AnnotationsSupport.callOnTeardownAnnotations(metadataProvider);
     }
 
     @Test
diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicHTTPMetadataResolverTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicHTTPMetadataResolverTest.java
index 1e5d0b1bf..717cb0697 100644
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicHTTPMetadataResolverTest.java
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicHTTPMetadataResolverTest.java
@@ -38,6 +38,7 @@ import org.testng.annotations.Test;
 
 import net.shibboleth.shared.httpclient.HttpClientBuilder;
 import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.AnnotationsSupport;
 import net.shibboleth.shared.resolver.CriteriaSet;
 import net.shibboleth.shared.resolver.Criterion;
 import net.shibboleth.shared.resolver.ResolverException;
@@ -80,9 +81,7 @@ public class AbstractDynamicHTTPMetadataResolverTest extends XMLObjectBaseTestCa
     
     @AfterMethod
     public void tearDown() {
-        if (resolver != null) {
-            resolver.destroy();
-        }
+        AnnotationsSupport.callOnTeardownAnnotations(resolver);
     }
     
     @Test
diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolverTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolverTest.java
index ed99a17d3..0154afdda 100644
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolverTest.java
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolverTest.java
@@ -77,6 +77,7 @@ import com.google.common.collect.Iterables;
 import net.shibboleth.shared.collection.CollectionSupport;
 import net.shibboleth.shared.component.ComponentInitializationException;
 import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.AnnotationsSupport;
 import net.shibboleth.shared.resolver.CriteriaSet;
 import net.shibboleth.shared.resolver.ResolverException;
 
@@ -182,9 +183,7 @@ public class AbstractDynamicMetadataResolverTest extends XMLObjectBaseTestCase {
     
     @AfterMethod
     protected void tearDown() {
-        if (resolver != null) {
-            resolver.destroy();
-        }
+        AnnotationsSupport.callOnTeardownAnnotations(resolver);
     }
 
     
diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/FunctionDrivenDynamicHTTPMetadataResolverTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/FunctionDrivenDynamicHTTPMetadataResolverTest.java
index 88293fa33..5e38d9a77 100644
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/FunctionDrivenDynamicHTTPMetadataResolverTest.java
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/FunctionDrivenDynamicHTTPMetadataResolverTest.java
@@ -50,6 +50,7 @@ import net.shibboleth.shared.codec.StringDigester;
 import net.shibboleth.shared.codec.StringDigester.OutputFormat;
 import net.shibboleth.shared.collection.CollectionSupport;
 import net.shibboleth.shared.httpclient.HttpClientBuilder;
+import net.shibboleth.shared.primitive.AnnotationsSupport;
 import net.shibboleth.shared.primitive.NonnullSupplier;
 import net.shibboleth.shared.resolver.CriteriaSet;
 import net.shibboleth.shared.resource.Resource;
@@ -112,9 +113,7 @@ public class FunctionDrivenDynamicHTTPMetadataResolverTest extends XMLObjectBase
     
     @AfterMethod
     public void tearDown() {
-        if (resolver != null) {
-            resolver.destroy();
-        }
+        AnnotationsSupport.callOnTeardownAnnotations(resolver);
     }
     
     
diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/LocalDynamicMetadataResolverTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/LocalDynamicMetadataResolverTest.java
index ef91b1c26..87c72ef33 100644
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/LocalDynamicMetadataResolverTest.java
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/LocalDynamicMetadataResolverTest.java
@@ -38,6 +38,7 @@ import net.shibboleth.shared.codec.StringDigester;
 import net.shibboleth.shared.codec.StringDigester.OutputFormat;
 import net.shibboleth.shared.component.ComponentInitializationException;
 import net.shibboleth.shared.logic.PredicateSupport;
+import net.shibboleth.shared.primitive.AnnotationsSupport;
 import net.shibboleth.shared.resolver.CriteriaSet;
 import net.shibboleth.shared.resolver.ResolverException;
 
@@ -81,9 +82,7 @@ public class LocalDynamicMetadataResolverTest extends XMLObjectBaseTestCase {
     
     @AfterMethod
     public void tearDown() {
-        if (resolver != null) {
-            resolver.destroy();
-        }
+        AnnotationsSupport.callOnTeardownAnnotations(resolver);
     }
     
     @Test
@@ -166,7 +165,7 @@ public class LocalDynamicMetadataResolverTest extends XMLObjectBaseTestCase {
 
     @Test
     public void testCtorSourceKeyGenerator() throws ComponentInitializationException, IOException, ResolverException {
-        resolver.destroy();
+        AnnotationsSupport.callOnTeardownAnnotations(resolver);
         
         resolver = new LocalDynamicMetadataResolver(null, sourceManager, new IdentityEntityIDGenerator());
         resolver.setId("abc123");
diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/assertion/impl/OneTimeUseConditionValidatorTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/assertion/impl/OneTimeUseConditionValidatorTest.java
index 10bbb0e5b..e4d0ee0f4 100644
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/assertion/impl/OneTimeUseConditionValidatorTest.java
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/assertion/impl/OneTimeUseConditionValidatorTest.java
@@ -18,6 +18,7 @@ import java.time.Duration;
 import java.util.Map;
 
 import net.shibboleth.shared.component.ComponentInitializationException;
+import net.shibboleth.shared.primitive.AnnotationsSupport;
 import net.shibboleth.shared.primitive.StringSupport;
 
 import org.opensaml.saml.common.assertion.AssertionValidationException;
@@ -67,8 +68,8 @@ public class OneTimeUseConditionValidatorTest extends BaseAssertionValidationTes
     
     @AfterMethod
     public void tearDown() {
-        replayCache.destroy();
-        storageService.destroy();
+        AnnotationsSupport.callOnTeardownAnnotations(replayCache);
+        AnnotationsSupport.callOnTeardownAnnotations(storageService);
     }
     
     @Test
diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/profile/impl/AddNameIDToSubjectsTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/profile/impl/AddNameIDToSubjectsTest.java
index e85b7ba55..4694eb3d9 100644
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/profile/impl/AddNameIDToSubjectsTest.java
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/profile/impl/AddNameIDToSubjectsTest.java
@@ -26,6 +26,7 @@ import javax.annotation.Nonnull;
 import net.shibboleth.shared.collection.CollectionSupport;
 import net.shibboleth.shared.component.ComponentInitializationException;
 import net.shibboleth.shared.logic.PredicateSupport;
+import net.shibboleth.shared.primitive.AnnotationsSupport;
 import net.shibboleth.shared.resolver.ResolverException;
 
 import org.opensaml.core.testing.XMLObjectBaseTestCase;
@@ -84,7 +85,7 @@ public class AddNameIDToSubjectsTest extends XMLObjectBaseTestCase {
     
     @AfterClass
     public void classTearDown() {
-        metadataResolver.destroy();
+        AnnotationsSupport.callOnTeardownAnnotations(metadataResolver);
     }
     
     @BeforeMethod
diff --git a/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/MemoryStorageServiceTest.java b/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/MemoryStorageServiceTest.java
index 1b050a5dd..3626fa705 100644
--- a/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/MemoryStorageServiceTest.java
+++ b/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/MemoryStorageServiceTest.java
@@ -48,7 +48,6 @@ public class MemoryStorageServiceTest extends StorageServiceTest {
         MemoryStorageService ss = new MemoryStorageService();
         ss.setId("test");
         ss.initialize();
-        ss.destroy();
     }
     
 }
\ No newline at end of file
diff --git a/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/StorageServiceReplayCacheTest.java b/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/StorageServiceReplayCacheTest.java
index 5adb41523..4a1076e8f 100644
--- a/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/StorageServiceReplayCacheTest.java
+++ b/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/StorageServiceReplayCacheTest.java
@@ -19,6 +19,9 @@ import java.time.Instant;
 import org.opensaml.storage.impl.client.ClientStorageService;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.Test;
+
+import net.shibboleth.shared.primitive.AnnotationsSupport;
+
 import org.testng.annotations.BeforeMethod;
 import org.testng.Assert;
 
@@ -54,10 +57,9 @@ public class StorageServiceReplayCacheTest {
     
     @AfterMethod
     protected void tearDown() {
-        replayCache.destroy();
         replayCache = null;
         
-        storageService.destroy();
+        AnnotationsSupport.callOnTeardownAnnotations(storageService);
         storageService = null;
     }
     
diff --git a/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/StorageServiceRevocationCacheTest.java b/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/StorageServiceRevocationCacheTest.java
index 0a50c0b01..bb4ef0e62 100644
--- a/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/StorageServiceRevocationCacheTest.java
+++ b/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/StorageServiceRevocationCacheTest.java
@@ -27,6 +27,7 @@ import org.testng.annotations.Test;
 
 import net.shibboleth.shared.component.ComponentInitializationException;
 import net.shibboleth.shared.logic.ConstraintViolationException;
+import net.shibboleth.shared.primitive.AnnotationsSupport;
 
 import org.testng.annotations.BeforeMethod;
 
@@ -57,8 +58,7 @@ public class StorageServiceRevocationCacheTest {
     
     @AfterMethod
     protected void tearDown() {
-        revocationCache.destroy();
-        storageService.destroy();
+        AnnotationsSupport.callOnTeardownAnnotations(storageService);
     }
     
     @Test
diff --git a/opensaml-testing/src/main/java/org/opensaml/storage/testing/StorageServiceTest.java b/opensaml-testing/src/main/java/org/opensaml/storage/testing/StorageServiceTest.java
index a12ae1b18..ceae616ee 100644
--- a/opensaml-testing/src/main/java/org/opensaml/storage/testing/StorageServiceTest.java
+++ b/opensaml-testing/src/main/java/org/opensaml/storage/testing/StorageServiceTest.java
@@ -40,6 +40,7 @@ import org.testng.annotations.Test;
 import net.shibboleth.shared.component.ComponentInitializationException;
 import net.shibboleth.shared.component.DestructableComponent;
 import net.shibboleth.shared.component.InitializableComponent;
+import net.shibboleth.shared.primitive.AnnotationsSupport;
 
 /**
  * Test of {@link StorageService} implementations.
@@ -76,9 +77,7 @@ public abstract class StorageServiceTest {
     
     @AfterClass
     protected void tearDown() {
-        if (shared instanceof DestructableComponent) {
-            ((DestructableComponent) shared).destroy();
-        }
+        AnnotationsSupport.callOnTeardownAnnotations(shared);
     }
     
     /**

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


More information about the commits mailing list