[java-shib-shared] 05/05: JSSH-71 Remove the impact of the DestructableComponent Interface

Codeberg noreply at shibboleth.net
Mon Jul 20 12:31: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-shib-shared.

View the commit online:
https://codeberg.org/Shibboleth/java-shib-shared/commit/b83a5693b2971b70d49949575f5bb6f2762848bd

commit b83a5693b2971b70d49949575f5bb6f2762848bd
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Sun Jul 19 16:23:36 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 isDestroyed and stop using default-destroy-method
---
 .../service/ReloadableSpringServiceTest.java       | 25 +++++++++-------------
 .../spring/service/TestServiceableComponent.java   |  1 +
 .../shared/spring/service/ReloadableBeans1.xml     |  3 +--
 .../spring/service/ReloadableSpringService.xml     |  3 +--
 .../shared/spring/service/ServiceableBean1.xml     |  3 +--
 .../shared/spring/service/ServiceableBean2.xml     |  3 +--
 6 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/shib-service/src/test/java/net/shibboleth/shared/spring/service/ReloadableSpringServiceTest.java b/shib-service/src/test/java/net/shibboleth/shared/spring/service/ReloadableSpringServiceTest.java
index b734c8ce..565ad14b 100644
--- a/shib-service/src/test/java/net/shibboleth/shared/spring/service/ReloadableSpringServiceTest.java
+++ b/shib-service/src/test/java/net/shibboleth/shared/spring/service/ReloadableSpringServiceTest.java
@@ -26,6 +26,7 @@ import javax.annotation.Nullable;
 
 import net.shibboleth.shared.collection.CollectionSupport;
 import net.shibboleth.shared.component.ComponentInitializationException;
+import net.shibboleth.shared.primitive.AnnotationsSupport;
 import net.shibboleth.shared.service.ServiceException;
 import net.shibboleth.shared.service.ServiceableComponent;
 import net.shibboleth.shared.spring.util.ApplicationContextBuilder;
@@ -96,7 +97,6 @@ public class ReloadableSpringServiceTest {
         final TestServiceableComponentChild child = component.getChild();
 
         Assert.assertEquals("One", component.getTheValue());
-        Assert.assertFalse(component.isDestroyed());
         Assert.assertFalse(child.tornDown);
 
         serviceableComponent.unpinComponent();
@@ -104,18 +104,17 @@ public class ReloadableSpringServiceTest {
 
         long count = 70;
 
-        while (count > 0 && !component.isDestroyed() && !component.tornDown) {
+        while (count > 0 && !component.tornDown) {
             Thread.sleep(RELOAD_DELAY.toMillis());
             count--;
         }
-        Assert.assertTrue(component.isDestroyed(), "After 7 second initial component has still not be destroyed");
         Assert.assertTrue(component.tornDown, "After 7 second initial component has still not been torn down");
         Assert.assertTrue(child.tornDown, "After 7 second initial child has still not been torn down");
 
         //
         // The reload will have destroyed the old component
         //
-        Assert.assertTrue(serviceableComponent.getComponent().isDestroyed());
+        Assert.assertTrue(((TestServiceableComponent) component).tornDown);
 
         serviceableComponent = service.getServiceableComponent();
         assert(serviceableComponent != null);
@@ -148,7 +147,6 @@ public class ReloadableSpringServiceTest {
         Assert.assertEquals(x,  service.getLastSuccessfulReloadInstant());
 
         Assert.assertEquals(component.getTheValue(), "One");
-        Assert.assertFalse(component.isDestroyed());
         Assert.assertFalse(component.tornDown);
 
         Thread.sleep(RELOAD_DELAY.toMillis() * 3);
@@ -159,7 +157,6 @@ public class ReloadableSpringServiceTest {
         //
         // The reload will not have destroyed the old component yet
         //
-        Assert.assertFalse(component.isDestroyed());
         Assert.assertFalse(component.tornDown);
 
         long count = 70;
@@ -179,13 +176,12 @@ public class ReloadableSpringServiceTest {
         Assert.assertNotNull(component2, "After 7 second initial component has still not got new value");
     
         count = 70;
-        while (count > 0 && !component.isDestroyed() && !component.tornDown) {
+        while (count > 0 && !component.tornDown) {
             Thread.sleep(RELOAD_DELAY.toMillis());
             count--;
         }
-        Assert.assertTrue(component.isDestroyed(), "After 7 second initial component has still not be destroyed");
         Assert.assertTrue(component.tornDown, "After 7 second initial component has still not been torn down");
-        service.destroy();
+        AnnotationsSupport.callOnTeardownAnnotations(service);
         deleteFile();
     }
 
@@ -225,7 +221,7 @@ public class ReloadableSpringServiceTest {
             // OK
         }
 
-        service.destroy();
+        AnnotationsSupport.callOnTeardownAnnotations(service);
         deleteFile();
     }
     @Test public void testNotFailFast() throws IOException, InterruptedException, ComponentInitializationException {
@@ -265,16 +261,15 @@ public class ReloadableSpringServiceTest {
         final TestServiceableComponent component = serviceableComponent.getComponent();
         Assert.assertEquals(component.getTheValue(), "Two");
 
-        Assert.assertFalse(component.isDestroyed());
+        Assert.assertFalse(component.tornDown);
         serviceableComponent.unpinComponent();
-        service.destroy();
-
+        AnnotationsSupport.callOnTeardownAnnotations(service);
         count = 70;
-        while (count > 0 && !component.isDestroyed()) {
+        while (count > 0 && !component.tornDown) {
             Thread.sleep(RELOAD_DELAY.toMillis());
             count--;
         }
-        Assert.assertTrue(component.isDestroyed(), "After 7 seconds component has still not be destroyed");
+        Assert.assertTrue(component.tornDown, "After 7 seconds component has still not be destroyed");
 
         deleteFile();
     }
diff --git a/shib-service/src/test/java/net/shibboleth/shared/spring/service/TestServiceableComponent.java b/shib-service/src/test/java/net/shibboleth/shared/spring/service/TestServiceableComponent.java
index 5e449280..2652227a 100644
--- a/shib-service/src/test/java/net/shibboleth/shared/spring/service/TestServiceableComponent.java
+++ b/shib-service/src/test/java/net/shibboleth/shared/spring/service/TestServiceableComponent.java
@@ -51,4 +51,5 @@ public class TestServiceableComponent extends AbstractIdentifiableInitializableC
     @OnTeardown public void teardown() {
         tornDown = true;
     }
+    
 }
diff --git a/shib-service/src/test/resources/net/shibboleth/shared/spring/service/ReloadableBeans1.xml b/shib-service/src/test/resources/net/shibboleth/shared/spring/service/ReloadableBeans1.xml
index 27ebbc2e..457de864 100644
--- a/shib-service/src/test/resources/net/shibboleth/shared/spring/service/ReloadableBeans1.xml
+++ b/shib-service/src/test/resources/net/shibboleth/shared/spring/service/ReloadableBeans1.xml
@@ -4,8 +4,7 @@
 	xmlns:p="http://www.springframework.org/schema/p"
 	xmlns:c="http://www.springframework.org/schema/c"
 	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"
-    default-init-method="initialize"
-    default-destroy-method="destroy">
+    default-init-method="initialize">
         
     <!-- This bean exists in the "top" level context. -->
     <bean id="nonReloadableBean" class="net.shibboleth.shared.spring.service.NonReloadableTestBean"
diff --git a/shib-service/src/test/resources/net/shibboleth/shared/spring/service/ReloadableSpringService.xml b/shib-service/src/test/resources/net/shibboleth/shared/spring/service/ReloadableSpringService.xml
index 07643e8b..be1a8a39 100644
--- a/shib-service/src/test/resources/net/shibboleth/shared/spring/service/ReloadableSpringService.xml
+++ b/shib-service/src/test/resources/net/shibboleth/shared/spring/service/ReloadableSpringService.xml
@@ -5,8 +5,7 @@
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd                           
                            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"
 
-       default-init-method="initialize"
-       default-destroy-method="destroy">
+       default-init-method="initialize">
 
     <bean id="testReloadableSpringService" class="net.shibboleth.shared.spring.service.ReloadableSpringService">
         <constructor-arg value="net.shibboleth.shared.spring.service.TestServiceableComponent" />
diff --git a/shib-service/src/test/resources/net/shibboleth/shared/spring/service/ServiceableBean1.xml b/shib-service/src/test/resources/net/shibboleth/shared/spring/service/ServiceableBean1.xml
index ee5c695e..16020a14 100644
--- a/shib-service/src/test/resources/net/shibboleth/shared/spring/service/ServiceableBean1.xml
+++ b/shib-service/src/test/resources/net/shibboleth/shared/spring/service/ServiceableBean1.xml
@@ -2,8 +2,7 @@
 <beans xmlns="http://www.springframework.org/schema/beans"
 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
 	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"
-    default-init-method="initialize"
-    default-destroy-method="destroy">
+    default-init-method="initialize">
 
 
 	<bean id="TheTestServiceableComponentOne"
diff --git a/shib-service/src/test/resources/net/shibboleth/shared/spring/service/ServiceableBean2.xml b/shib-service/src/test/resources/net/shibboleth/shared/spring/service/ServiceableBean2.xml
index 7c5257f0..44875abe 100644
--- a/shib-service/src/test/resources/net/shibboleth/shared/spring/service/ServiceableBean2.xml
+++ b/shib-service/src/test/resources/net/shibboleth/shared/spring/service/ServiceableBean2.xml
@@ -2,8 +2,7 @@
 <beans xmlns="http://www.springframework.org/schema/beans"
 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
 	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"
-    default-init-method="initialize"
-    default-destroy-method="destroy">
+    default-init-method="initialize">
 
 
 	<bean id="TheTestServiceableComponentTwo"

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


More information about the commits mailing list