[java-opensaml] 02/02: JSSH-71 Remove the impact of the DestructableComponent Interface
Codeberg
noreply at shibboleth.net
Thu Jul 9 12:44:40 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/cbced2f93adb9b083429e1456c51c1447402d835
commit cbced2f93adb9b083429e1456c51c1447402d835
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Tue Jul 7 16:05:51 2026 +0100
JSSH-71 Remove the impact of the DestructableComponent Interface
https://shibboleth.atlassian.net/browse/JSSH-71
Replace functional doDestroy methods with suitable annotations, leaving metrics tear down done by doDestroy
(for ease of location in V6).
---
.../action/AbstractHandlerDelegatingProfileAction.java | 15 ++++++++-------
.../binding/artifact/impl/BasicSAMLArtifactMap.java | 10 ++++++----
.../resolver/impl/AbstractDynamicMetadataResolver.java | 18 +++++++++++++++---
.../impl/AbstractReloadingMetadataResolver.java | 9 ++++-----
.../org/opensaml/storage/AbstractStorageService.java | 9 ++++++---
5 files changed, 39 insertions(+), 22 deletions(-)
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 ba0b5fa16..12043ed59 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
@@ -30,8 +30,9 @@ import org.opensaml.profile.context.navigate.ParentProfileRequestContextLookup;
import com.google.common.base.Predicates;
-import net.shibboleth.shared.component.DestructableComponent;
+import net.shibboleth.shared.annotation.OnTeardown;
import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.AnnotationsSupport;
import net.shibboleth.shared.primitive.StringSupport;
/**
@@ -99,12 +100,12 @@ public abstract class AbstractHandlerDelegatingProfileAction<DelegateType extend
errorEvent = StringSupport.trimOrNull(event);
}
- /** {@inheritDoc} */
- protected void doDestroy() {
- super.doDestroy();
- if (delegate != null && delegate instanceof DestructableComponent) {
- ((DestructableComponent) delegate).destroy();
- }
+ /**
+ * Tear down the bean when the ServiceableComponent it is part of is unloaded.
+ */
+ @OnTeardown
+ public final void teardownAbstractHandlerDelegatingProfileAction() {
+ AnnotationsSupport.callOnTeardownAnnotations(delegate);
}
/**
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/common/binding/artifact/impl/BasicSAMLArtifactMap.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/common/binding/artifact/impl/BasicSAMLArtifactMap.java
index 743fd8d5a..d67f89039 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/common/binding/artifact/impl/BasicSAMLArtifactMap.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/common/binding/artifact/impl/BasicSAMLArtifactMap.java
@@ -31,6 +31,7 @@ import org.opensaml.saml.common.binding.artifact.ExpiringSAMLArtifactMapEntry;
import org.opensaml.saml.common.binding.artifact.SAMLArtifactMap;
import org.slf4j.Logger;
+import net.shibboleth.shared.annotation.OnTeardown;
import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.component.AbstractInitializableComponent;
@@ -83,16 +84,17 @@ public class BasicSAMLArtifactMap extends AbstractInitializableComponent impleme
}
}
- /** {@inheritDoc} */
- @Override protected void doDestroy() {
+ /**
+ * Tear down worker tasks when the containing service reloads.
+ */
+ @OnTeardown
+ public final synchronized void teardownBasicSAMLArtifactMap() {
if (cleanupTask != null) {
cleanupTask.cancel();
cleanupTask = null;
cleanupTaskTimer = null;
}
artifactStore = null;
-
- super.doDestroy();
}
/**
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 68266ff9e..e9c48151a 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
@@ -62,6 +62,7 @@ import com.codahale.metrics.RatioGauge;
import com.codahale.metrics.Timer.Context;
import com.google.common.base.MoreObjects;
+import net.shibboleth.shared.annotation.OnTeardown;
import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.annotation.constraint.NotLive;
@@ -631,6 +632,9 @@ public abstract class AbstractDynamicMetadataResolver extends AbstractMetadataRe
@Nonnull protected Iterable<EntityDescriptor> doResolve(@Nullable final CriteriaSet criteria)
throws ResolverException {
checkComponentActive();
+ if (cleanupTask == null) {
+ log.warn("{} Called doResolve in a torn down resolver", getId());
+ }
final Context contextResolve = MetricsSupport.startTimer(timerResolve);
try {
@@ -1488,9 +1492,9 @@ public abstract class AbstractDynamicMetadataResolver extends AbstractMetadataRe
super.removeByEntityID(entityID, backingStore);
}
- /** {@inheritDoc} */
- @Override
- protected void doDestroy() {
+ /** Tear down when an embedding service refreshes. */
+ @OnTeardown
+ public void tearDownAbstractDynamicMetadataResolver() {
if (cleanupTask != null) {
cleanupTask.cancel();
}
@@ -1499,6 +1503,14 @@ public abstract class AbstractDynamicMetadataResolver extends AbstractMetadataRe
}
cleanupTask = null;
taskTimer = null;
+ }
+
+ /** {@inheritDoc}
+ *
+ * This just tears down metrics and will be removed in V6.
+ */
+ @Override
+ protected void doDestroy() {
if (ratioGaugeFetchToResolve != null) {
MetricsSupport.remove(MetricRegistry.name(getMetricsBaseName(), METRIC_RATIOGAUGE_FETCH_TO_RESOLVE),
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractReloadingMetadataResolver.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractReloadingMetadataResolver.java
index e69a327e2..9c1ea10ff 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractReloadingMetadataResolver.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractReloadingMetadataResolver.java
@@ -41,6 +41,7 @@ import org.w3c.dom.Element;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer.Context;
+import net.shibboleth.shared.annotation.OnTeardown;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.component.ComponentInitializationException;
import net.shibboleth.shared.logic.Constraint;
@@ -298,9 +299,9 @@ public abstract class AbstractReloadingMetadataResolver extends AbstractBatchMet
minRefreshDelay = delay;
}
- /** {@inheritDoc} */
- @Override
- protected void doDestroy() {
+ /** Tear down when an embedding service refreshes. */
+ @OnTeardown
+ public void tearDownAbstractDynamicMetadataResolver() {
if (refreshMetadataTask != null) {
refreshMetadataTask.cancel();
}
@@ -308,8 +309,6 @@ public abstract class AbstractReloadingMetadataResolver extends AbstractBatchMet
if (createdOwnTaskTimer) {
taskTimer.cancel();
}
-
- super.doDestroy();
}
/** {@inheritDoc} */
diff --git a/opensaml-storage-api/src/main/java/org/opensaml/storage/AbstractStorageService.java b/opensaml-storage-api/src/main/java/org/opensaml/storage/AbstractStorageService.java
index b77316a49..d60e56fb5 100644
--- a/opensaml-storage-api/src/main/java/org/opensaml/storage/AbstractStorageService.java
+++ b/opensaml-storage-api/src/main/java/org/opensaml/storage/AbstractStorageService.java
@@ -24,6 +24,7 @@ import javax.annotation.Nullable;
import org.opensaml.storage.annotation.AnnotationSupport;
+import net.shibboleth.shared.annotation.OnTeardown;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.annotation.constraint.Positive;
import net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent;
@@ -180,8 +181,11 @@ public abstract class AbstractStorageService extends AbstractIdentifiableInitial
}
}
- /** {@inheritDoc} */
- @Override protected void doDestroy() {
+ /**
+ * Tear down worker tasks when the containing service reloads.
+ */
+ @OnTeardown
+ public final synchronized void teardownAbstractStorageService() {
if (cleanupTask != null) {
cleanupTask.cancel();
cleanupTask = null;
@@ -191,7 +195,6 @@ public abstract class AbstractStorageService extends AbstractIdentifiableInitial
}
internalTaskTimer = null;
}
- super.doDestroy();
}
/** {@inheritDoc} */
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list