[java-opensaml] branch dev/JSSH-71 updated: JSSH-71 Remove the impact of the DestructableComponent Interface
Codeberg
noreply at shibboleth.net
Tue May 26 13:28:22 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch dev/JSSH-71
in repository java-opensaml.
View the commit online:
https://codeberg.org/Shibboleth/java-opensaml/commit/b20e956d596ae7e10743e2a67a32c1171566c1c4
The following commit(s) were added to refs/heads/dev/JSSH-71 by this push:
new b20e956d5 JSSH-71 Remove the impact of the DestructableComponent Interface
b20e956d5 is described below
commit b20e956d596ae7e10743e2a67a32c1171566c1c4
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Mon May 25 20:24:29 2026 +0100
JSSH-71 Remove the impact of the DestructableComponent Interface
https://shibboleth.atlassian.net/browse/JSSH-71
Remove explicit use of destroy() across all OpenSAML.
In many places we swap this for an explicit call into Support
to call an @PreDestroy annotated function or an assert (even in
run time code for now, maybe make it a constraint later)
that the object doesn't have such an annotated method.
---
.../opensaml/messaging/decoder/AbstractMessageDecoder.java | 3 +--
.../java/org/opensaml/messaging/decoder/MessageDecoder.java | 3 +--
.../opensaml/messaging/encoder/AbstractMessageEncoder.java | 2 --
.../java/org/opensaml/messaging/encoder/MessageEncoder.java | 6 ++----
.../action/AbstractHandlerDelegatingProfileAction.java | 3 +++
opensaml-profile-impl/pom.xml | 6 +++++-
.../java/org/opensaml/profile/action/impl/DecodeMessage.java | 5 ++---
.../java/org/opensaml/profile/action/impl/EncodeMessage.java | 6 +++---
opensaml-saml-impl/pom.xml | 10 +++++-----
.../resolver/impl/AbstractDynamicMetadataResolver.java | 6 ++----
.../security/impl/MessageReplaySecurityHandlerTest.java | 10 +++++-----
.../profile/logic/tests/EntityGroupNamePredicateTest.java | 7 +++++--
.../impl/AbstractDynamicHTTPMetadataResolverTest.java | 5 ++---
.../resolver/impl/AbstractDynamicMetadataResolverTest.java | 5 ++---
.../impl/FunctionDrivenDynamicHTTPMetadataResolverTest.java | 5 ++---
.../resolver/impl/LocalDynamicMetadataResolverTest.java | 7 +++----
.../assertion/impl/OneTimeUseConditionValidatorTest.java | 7 +++++--
.../saml/saml2/profile/impl/AddNameIDToSubjectsTest.java | 3 ++-
.../soap/client/http/AbstractPipelineHttpSOAPClient.java | 7 +++----
opensaml-storage-api/pom.xml | 4 ++--
opensaml-storage-impl/pom.xml | 10 +++++-----
.../org/opensaml/storage/impl/MemoryStorageServiceTest.java | 1 -
.../opensaml/storage/impl/StorageServiceReplayCacheTest.java | 11 +++++++----
.../storage/impl/StorageServiceRevocationCacheTest.java | 5 +++--
.../storage/impl/memcached/MemcachedStorageServiceTest.java | 5 +++--
.../java/org/opensaml/storage/testing/StorageServiceTest.java | 6 ++----
26 files changed, 75 insertions(+), 73 deletions(-)
diff --git a/opensaml-messaging-api/src/main/java/org/opensaml/messaging/decoder/AbstractMessageDecoder.java b/opensaml-messaging-api/src/main/java/org/opensaml/messaging/decoder/AbstractMessageDecoder.java
index 5e8458d62..f089e7e92 100644
--- a/opensaml-messaging-api/src/main/java/org/opensaml/messaging/decoder/AbstractMessageDecoder.java
+++ b/opensaml-messaging-api/src/main/java/org/opensaml/messaging/decoder/AbstractMessageDecoder.java
@@ -142,8 +142,7 @@ public abstract class AbstractMessageDecoder extends AbstractInitializableCompon
}
/**
- * Performs the decoding logic. By the time this is called, this decoder has already been initialized and checked to
- * ensure that it has not been destroyed.
+ * Performs the decoding logic. By the time this is called, this decoder has already been initialized.
*
* @throws MessageDecodingException thrown if there is a problem decoding the message
*/
diff --git a/opensaml-messaging-api/src/main/java/org/opensaml/messaging/decoder/MessageDecoder.java b/opensaml-messaging-api/src/main/java/org/opensaml/messaging/decoder/MessageDecoder.java
index 5492d4f2f..34b893c54 100644
--- a/opensaml-messaging-api/src/main/java/org/opensaml/messaging/decoder/MessageDecoder.java
+++ b/opensaml-messaging-api/src/main/java/org/opensaml/messaging/decoder/MessageDecoder.java
@@ -23,8 +23,7 @@ import net.shibboleth.shared.component.InitializableComponent;
/**
* Interface for component that decodes message data from a source into a {@link MessageContext}. Before the decoder can
- * be used the {@link #initialize()} method must be called. After the decoder has been used the {@link #destroy()}
- * method should be invoked in order to clean up any resources.
+ * be used the {@link #initialize()} method must be called.
*
* <p>
* The data on which the decoder operates is supplied in an implementation-specific manner.
diff --git a/opensaml-messaging-api/src/main/java/org/opensaml/messaging/encoder/AbstractMessageEncoder.java b/opensaml-messaging-api/src/main/java/org/opensaml/messaging/encoder/AbstractMessageEncoder.java
index fa836b956..cd2eb9ab9 100644
--- a/opensaml-messaging-api/src/main/java/org/opensaml/messaging/encoder/AbstractMessageEncoder.java
+++ b/opensaml-messaging-api/src/main/java/org/opensaml/messaging/encoder/AbstractMessageEncoder.java
@@ -168,8 +168,6 @@ public abstract class AbstractMessageEncoder extends AbstractInitializableCompon
}
/**
- * Performs the encoding logic. By the time this is called, this encoder has already been initialized and checked to
- * ensure that it has not been destroyed.
*
* @throws MessageEncodingException thrown if there is a problem encoding the message
*/
diff --git a/opensaml-messaging-api/src/main/java/org/opensaml/messaging/encoder/MessageEncoder.java b/opensaml-messaging-api/src/main/java/org/opensaml/messaging/encoder/MessageEncoder.java
index 360dcbfa1..daaa20c2d 100644
--- a/opensaml-messaging-api/src/main/java/org/opensaml/messaging/encoder/MessageEncoder.java
+++ b/opensaml-messaging-api/src/main/java/org/opensaml/messaging/encoder/MessageEncoder.java
@@ -18,19 +18,17 @@ import javax.annotation.Nullable;
import org.opensaml.messaging.context.MessageContext;
-import net.shibboleth.shared.component.DestructableComponent;
import net.shibboleth.shared.component.InitializableComponent;
/**
* Interface for component that encodes message data from a {@link MessageContext} to a sink. Before the encoder can be
- * used the {@link #initialize()} method must be called. After the encoder has been used the {@link #destroy()} should
- * be invoked in order to clean up any resources.
+ * used the {@link #initialize()} method must be called.
*
* <p>
* The sink data or structure on which the encoder operates is supplied in an implementation-specific manner.
* </p>
*/
-public interface MessageEncoder extends InitializableComponent, DestructableComponent {
+public interface MessageEncoder extends InitializableComponent {
/**
* This method should prepare the message context by creating and populating any binding-specific data structures
diff --git a/opensaml-profile-api/src/main/java/org/opensaml/profile/action/AbstractHandlerDelegatingProfileAction.java b/opensaml-profile-api/src/main/java/org/opensaml/profile/action/AbstractHandlerDelegatingProfileAction.java
index 262231e6e..efd3a25a5 100644
--- a/opensaml-profile-api/src/main/java/org/opensaml/profile/action/AbstractHandlerDelegatingProfileAction.java
+++ b/opensaml-profile-api/src/main/java/org/opensaml/profile/action/AbstractHandlerDelegatingProfileAction.java
@@ -31,6 +31,7 @@ import org.opensaml.profile.context.navigate.ParentProfileRequestContextLookup;
import com.google.common.base.Predicates;
import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.AnnotationsSupport;
import net.shibboleth.shared.primitive.StringSupport;
/**
@@ -72,6 +73,7 @@ public abstract class AbstractHandlerDelegatingProfileAction<DelegateType extend
InvocationTargetException | NoSuchMethodException | SecurityException e) {
throw new RuntimeException(e);
}
+ assert !AnnotationsSupport.hasPreDestroyAnnotation(delegate);
messageContextLookup = Constraint.isNotNull(lookup, "MessageContext lookup function may not be null");
}
@@ -87,6 +89,7 @@ public abstract class AbstractHandlerDelegatingProfileAction<DelegateType extend
@Nonnull final ContextDataLookupFunction<ProfileRequestContext, MessageContext> lookup) {
delegate = Constraint.isNotNull(delegateInstance, "Delegate instance may not be null");
messageContextLookup = Constraint.isNotNull(lookup, "MessageContext lookup function may not be null");
+ assert !AnnotationsSupport.hasPreDestroyAnnotation(delegate);
}
/**
diff --git a/opensaml-profile-impl/pom.xml b/opensaml-profile-impl/pom.xml
index 1ea9c4527..64fb9e585 100644
--- a/opensaml-profile-impl/pom.xml
+++ b/opensaml-profile-impl/pom.xml
@@ -60,7 +60,11 @@
<dependency>
<groupId>${shib-shared.groupId}</groupId>
<artifactId>shib-security</artifactId>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>${shib-shared.groupId}</groupId>
+ <artifactId>shib-support</artifactId>
+ </dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
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..d8b944eef 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
@@ -27,6 +27,7 @@ import org.opensaml.profile.context.ProfileRequestContext;
import org.slf4j.Logger;
import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.AnnotationsSupport;
import net.shibboleth.shared.primitive.LoggerFactory;
/**
@@ -37,7 +38,6 @@ import net.shibboleth.shared.primitive.LoggerFactory;
* @event {@link EventIds#INVALID_MESSAGE}
*
* @post If decode succeeds, ProfileRequestContext.getInboundMessageContext() != null
- * @post The injected {@link MessageDecoder} is destroyed.
*/
public class DecodeMessage extends AbstractProfileAction {
@@ -97,8 +97,7 @@ public class DecodeMessage extends AbstractProfileAction {
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();
+ assert !AnnotationsSupport.hasPreDestroyAnnotation(decoder);
}
}
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..6f95c2a5e 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
@@ -22,6 +22,7 @@ import javax.annotation.Nullable;
import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
import net.shibboleth.shared.component.ComponentInitializationException;
import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.AnnotationsSupport;
import net.shibboleth.shared.primitive.LoggerFactory;
import org.opensaml.messaging.context.MessageContext;
@@ -39,7 +40,7 @@ import org.slf4j.Logger;
* Action that encodes an outbound response from the outbound {@link MessageContext}.
*
* <p>The input to {@link #setMessageEncoderFactory(Function)} is used to obtain a new
- * {@link MessageEncoder} to use, and the encoder is destroyed upon completion.</p>
+ * {@link MessageEncoder} to use.</p>
*
*
* @event {@link EventIds#PROCEED_EVENT_ID}
@@ -166,8 +167,7 @@ public class EncodeMessage extends AbstractProfileAction {
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();
+ assert !AnnotationsSupport.hasPreDestroyAnnotation(encoder);
}
}
diff --git a/opensaml-saml-impl/pom.xml b/opensaml-saml-impl/pom.xml
index 028b4891a..3f7f9dc21 100644
--- a/opensaml-saml-impl/pom.xml
+++ b/opensaml-saml-impl/pom.xml
@@ -140,16 +140,16 @@
<artifactId>${httpclient.httpcore.artifactId}</artifactId>
</dependency>
+ <dependency>
+ <groupId>jakarta.annotation</groupId>
+ <artifactId>jakarta.annotation-api</artifactId>
+ </dependency>
+
<!-- Provided Dependencies -->
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
</dependency>
- <dependency>
- <groupId>jakarta.annotation</groupId>
- <artifactId>jakarta.annotation-api</artifactId>
- <scope>provided</scope>
- </dependency>
<!-- Runtime Dependencies -->
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java
index 403ea54e3..681a62114 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java
@@ -37,8 +37,6 @@ import java.util.function.Predicate;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import jakarta.annotation.PreDestroy;
-
import org.opensaml.core.criterion.EntityIdCriterion;
import org.opensaml.core.metrics.MetricsSupport;
import org.opensaml.core.xml.XMLObject;
@@ -56,7 +54,6 @@ import org.opensaml.saml.saml2.common.SAML2Support;
import org.opensaml.saml.saml2.metadata.EntitiesDescriptor;
import org.opensaml.saml.saml2.metadata.EntityDescriptor;
import org.opensaml.security.crypto.JCAConstants;
-
import org.slf4j.Logger;
import com.codahale.metrics.Gauge;
@@ -65,6 +62,7 @@ import com.codahale.metrics.RatioGauge;
import com.codahale.metrics.Timer.Context;
import com.google.common.base.MoreObjects;
+import jakarta.annotation.PreDestroy;
import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.annotation.constraint.NotLive;
@@ -1316,7 +1314,7 @@ public abstract class AbstractDynamicMetadataResolver extends AbstractMetadataRe
assert timerFetchFromOriginSource2 != null;
// Note that these gauges must use the support method to register in a synchronized fashion,
- // and also must store off the instances for later use in destroy.
+ // and also must store off the instances for later use in teardown.
ratioGaugeFetchToResolve = MetricsSupport.register(
MetricRegistry.name(getMetricsBaseName(), METRIC_RATIOGAUGE_FETCH_TO_RESOLVE),
new RatioGauge() {
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..f11b1db19 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
@@ -14,6 +14,8 @@
package org.opensaml.saml.common.binding.security.impl;
+import static org.testng.Assert.assertFalse;
+
import java.time.Duration;
import org.opensaml.core.testing.XMLObjectBaseTestCase;
@@ -28,6 +30,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,11 +74,8 @@ public class MessageReplaySecurityHandlerTest extends XMLObjectBaseTestCase {
protected void tearDown() {
handler = null;
- replayCache.destroy();
- replayCache = null;
-
- storageService.destroy();
- storageService = null;
+ assertFalse(AnnotationsSupport.hasPreDestroyAnnotation(replayCache));
+ AnnotationsSupport.callPreDestroyAnnotation(storageService);
}
/**
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..5b548e9b7 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,9 +15,12 @@
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;
+import static org.testng.Assert.assertFalse;
+
import org.opensaml.core.criterion.EntityIdCriterion;
import org.opensaml.core.testing.XMLObjectBaseTestCase;
import org.opensaml.saml.common.profile.logic.EntityGroupNamePredicate;
@@ -61,8 +64,8 @@ public class EntityGroupNamePredicateTest extends XMLObjectBaseTestCase {
@AfterClass
protected void tearDown() {
- metadataProvider.destroy();
- filter.destroy();
+ AnnotationsSupport.callPreDestroyAnnotation(metadataProvider);
+ assertFalse(AnnotationsSupport.hasPreDestroyAnnotation(filter));
}
@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..d6e653348 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.callPreDestroyAnnotation(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..2895192cb 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.callPreDestroyAnnotation(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 e4b3e5307..4333db6b1 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
@@ -38,6 +38,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.resolver.CriteriaSet;
import net.shibboleth.shared.testing.RepositorySupport;
import net.shibboleth.shared.testing.VelocityEngine;
@@ -56,9 +57,7 @@ public class FunctionDrivenDynamicHTTPMetadataResolverTest extends XMLObjectBase
@AfterMethod
public void tearDown() {
- if (resolver != null) {
- resolver.destroy();
- }
+ AnnotationsSupport.callPreDestroyAnnotation(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..f7e4f5249 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.callPreDestroyAnnotation(resolver);
}
@Test
@@ -166,7 +165,7 @@ public class LocalDynamicMetadataResolverTest extends XMLObjectBaseTestCase {
@Test
public void testCtorSourceKeyGenerator() throws ComponentInitializationException, IOException, ResolverException {
- resolver.destroy();
+ AnnotationsSupport.callPreDestroyAnnotation(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..f21380ef6 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
@@ -14,10 +14,13 @@
package org.opensaml.saml.saml2.assertion.impl;
+import static org.testng.Assert.assertFalse;
+
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 +70,8 @@ public class OneTimeUseConditionValidatorTest extends BaseAssertionValidationTes
@AfterMethod
public void tearDown() {
- replayCache.destroy();
- storageService.destroy();
+ assertFalse(AnnotationsSupport.hasPreDestroyAnnotation(replayCache));
+ AnnotationsSupport.callPreDestroyAnnotation(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..2486e9899 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.callPreDestroyAnnotation(metadataResolver);
}
@BeforeMethod
diff --git a/opensaml-soap-api/src/main/java/org/opensaml/soap/client/http/AbstractPipelineHttpSOAPClient.java b/opensaml-soap-api/src/main/java/org/opensaml/soap/client/http/AbstractPipelineHttpSOAPClient.java
index 68120219f..91d072c32 100644
--- a/opensaml-soap-api/src/main/java/org/opensaml/soap/client/http/AbstractPipelineHttpSOAPClient.java
+++ b/opensaml-soap-api/src/main/java/org/opensaml/soap/client/http/AbstractPipelineHttpSOAPClient.java
@@ -59,6 +59,7 @@ import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.component.AbstractInitializableComponent;
import net.shibboleth.shared.component.ComponentInitializationException;
import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.AnnotationsSupport;
import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.shared.resolver.CriteriaSet;
@@ -233,10 +234,8 @@ public abstract class AbstractPipelineHttpSOAPClient
} catch (final IOException e) {
throw new SOAPException("I/O problem with SOAP message exchange with: " + endpoint, e);
} finally {
- if (pipeline != null) {
- pipeline.getEncoder().destroy();
- pipeline.getDecoder().destroy();
- }
+ assert !AnnotationsSupport.hasPreDestroyAnnotation(pipeline.getDecoder());
+ assert !AnnotationsSupport.hasPreDestroyAnnotation(pipeline.getEncoder());
}
}
// Checkstyle: CyclomaticComplexity|MethodLength ON
diff --git a/opensaml-storage-api/pom.xml b/opensaml-storage-api/pom.xml
index 5289ce470..cb1641303 100644
--- a/opensaml-storage-api/pom.xml
+++ b/opensaml-storage-api/pom.xml
@@ -27,13 +27,13 @@
<version>${project.version}</version>
</dependency>
- <!-- Provided Dependencies -->
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
- <scope>provided</scope>
</dependency>
+ <!-- Provided Dependencies -->
+
<!-- Runtime Dependencies -->
<!-- Test Dependencies -->
diff --git a/opensaml-storage-impl/pom.xml b/opensaml-storage-impl/pom.xml
index e8bb1d013..701e37d49 100644
--- a/opensaml-storage-impl/pom.xml
+++ b/opensaml-storage-impl/pom.xml
@@ -71,6 +71,11 @@
<artifactId>commons-codec</artifactId>
</dependency>
+ <dependency>
+ <groupId>jakarta.annotation</groupId>
+ <artifactId>jakarta.annotation-api</artifactId>
+ </dependency>
+
<!-- Provided Dependencies -->
<dependency>
<groupId>jakarta.json</groupId>
@@ -82,11 +87,6 @@
<artifactId>jakarta.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>jakarta.annotation</groupId>
- <artifactId>jakarta.annotation-api</artifactId>
- <scope>provided</scope>
- </dependency>
<!-- Runtime Dependencies -->
<dependency>
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..c4ddad605 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
@@ -14,11 +14,16 @@
package org.opensaml.storage.impl;
+import static org.testng.Assert.assertFalse;
+
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,11 +59,9 @@ public class StorageServiceReplayCacheTest {
@AfterMethod
protected void tearDown() {
- replayCache.destroy();
- replayCache = null;
- storageService.destroy();
- storageService = null;
+ assertFalse(AnnotationsSupport.hasPreDestroyAnnotation(replayCache));
+ AnnotationsSupport.callPreDestroyAnnotation(storageService);
}
/**
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..a0aecf84f 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,8 @@ public class StorageServiceRevocationCacheTest {
@AfterMethod
protected void tearDown() {
- revocationCache.destroy();
- storageService.destroy();
+ assertFalse(AnnotationsSupport.hasPreDestroyAnnotation(revocationCache));
+ AnnotationsSupport.callPreDestroyAnnotation(storageService);
}
@Test
diff --git a/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/memcached/MemcachedStorageServiceTest.java b/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/memcached/MemcachedStorageServiceTest.java
index d1a676d47..51b53adae 100644
--- a/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/memcached/MemcachedStorageServiceTest.java
+++ b/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/memcached/MemcachedStorageServiceTest.java
@@ -17,6 +17,7 @@ package org.opensaml.storage.impl.memcached;
import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.collection.Pair;
import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.AnnotationsSupport;
import net.spy.memcached.BinaryConnectionFactory;
import net.spy.memcached.MemcachedClient;
import org.cryptacular.generator.IdGenerator;
@@ -217,8 +218,8 @@ public class MemcachedStorageServiceTest {
@AfterClass
public void tearDown() {
- service.destroy();
- keyTrackingService.destroy();
+ assertFalse(!AnnotationsSupport.hasPreDestroyAnnotation(service));
+ assertFalse(!AnnotationsSupport.hasPreDestroyAnnotation(keyTrackingService));
}
private Set<String> createContextKeys(final String context, final IdGenerator generator, final int count)
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..3e8b82702 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
@@ -38,8 +38,8 @@ import org.testng.annotations.BeforeClass;
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 +76,7 @@ public abstract class StorageServiceTest {
@AfterClass
protected void tearDown() {
- if (shared instanceof DestructableComponent) {
- ((DestructableComponent) shared).destroy();
- }
+ AnnotationsSupport.callPreDestroyAnnotation(shared);
}
/**
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list