[java-shib-shared] 03/03: JSSH-62 - Remove Lifecycle from ReloadableSpringService

Ian Young ian at iay.org.uk
Mon Aug 18 14:10:14 UTC 2025


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

iay pushed a commit to branch dev/JPAR-234
in repository java-shib-shared.

View the commit online:
http://git.shibboleth.net/view/?p=java-shib-shared.git;a=commit;h=714df295fd31ff8daf1f509bbec59bebb9d70f08

commit 714df295fd31ff8daf1f509bbec59bebb9d70f08
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Wed Jul 23 16:41:01 2025 +0100

    JSSH-62 - Remove Lifecycle from ReloadableSpringService
    
    This is not necessary, and the implementation conflicted with
    the behaviour expected in Spring Framework's TestContext
    Framework from 7.0.0-M5 onwards.
    
    https://shibboleth.atlassian.net/browse/JSSH-62
---
 .../spring/service/ReloadableSpringService.java    | 26 +---------------------
 .../service/ReloadableSpringServiceTest.java       | 26 +++++++++++-----------
 2 files changed, 14 insertions(+), 38 deletions(-)

diff --git a/shib-service/src/main/java/net/shibboleth/shared/spring/service/ReloadableSpringService.java b/shib-service/src/main/java/net/shibboleth/shared/spring/service/ReloadableSpringService.java
index 536dd7ca..88c934ec 100644
--- a/shib-service/src/main/java/net/shibboleth/shared/spring/service/ReloadableSpringService.java
+++ b/shib-service/src/main/java/net/shibboleth/shared/spring/service/ReloadableSpringService.java
@@ -27,13 +27,11 @@ import javax.annotation.concurrent.ThreadSafe;
 import org.slf4j.Logger;
 
 import org.springframework.beans.FatalBeanException;
-import org.springframework.beans.factory.BeanInitializationException;
 import org.springframework.beans.factory.BeanNameAware;
 import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
 import org.springframework.beans.factory.config.BeanPostProcessor;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
-import org.springframework.context.Lifecycle;
 import org.springframework.context.support.GenericApplicationContext;
 import org.springframework.core.convert.ConversionService;
 import org.springframework.core.io.Resource;
@@ -63,7 +61,7 @@ import net.shibboleth.shared.spring.util.ApplicationContextBuilder;
  */
 @ThreadSafe
 public class ReloadableSpringService<T> extends AbstractReloadableService<T> implements ApplicationContextAware,
-        BeanNameAware, Lifecycle {
+        BeanNameAware {
 
     /** Class logger. */
     @Nonnull private final Logger log = LoggerFactory.getLogger(ReloadableSpringService.class);
@@ -265,28 +263,6 @@ public class ReloadableSpringService<T> extends AbstractReloadableService<T> imp
         conversionService = service;
     }
 
-    /** {@inheritDoc} */
-    @Override
-    public final void start() {
-        try {
-            initialize();
-        } catch (final ComponentInitializationException e) {
-            throw new BeanInitializationException("Could not start service", e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public final void stop() {
-        destroy();
-    }
-
-    /** {@inheritDoc}. */
-    @Override
-    public boolean isRunning() {
-        return isInitialized() && !isDestroyed();
-    }
-
 
 // Checkstyle: CyclomaticComplexity OFF
     /** {@inheritDoc} */
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 e07fb8db..a5ef2faa 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
@@ -25,11 +25,11 @@ import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 import net.shibboleth.shared.collection.CollectionSupport;
+import net.shibboleth.shared.component.ComponentInitializationException;
 import net.shibboleth.shared.service.ServiceException;
 import net.shibboleth.shared.service.ServiceableComponent;
 import net.shibboleth.shared.spring.util.ApplicationContextBuilder;
 
-import org.springframework.beans.factory.BeanInitializationException;
 import org.springframework.context.support.GenericApplicationContext;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.core.io.FileSystemResource;
@@ -77,7 +77,7 @@ public class ReloadableSpringServiceTest {
         }
     }
 
-    @Test(enabled=true) public void reloadableService() throws IOException, InterruptedException {
+    @Test(enabled=true) public void reloadableService() throws IOException, InterruptedException, ComponentInitializationException {
         final ReloadableSpringService<TestServiceableComponent> service =
                 new ReloadableSpringService<>(TestServiceableComponent.class);
 
@@ -88,7 +88,7 @@ public class ReloadableSpringServiceTest {
         service.setReloadCheckDelay(RELOAD_DELAY);
         service.setServiceConfigurations(CollectionSupport.singletonList(testFileResource()));
 
-        service.start();
+        service.initialize();
 
         AbstractServiceableComponent<TestServiceableComponent> serviceableComponent = service.getServiceableComponent();
         assert(serviceableComponent != null);
@@ -117,12 +117,12 @@ public class ReloadableSpringServiceTest {
 
         Assert.assertEquals(serviceableComponent.getComponent().getTheValue(), "Two");
         serviceableComponent.unpinComponent();
-        service.stop();
+        service.destroy();
         
         deleteFile();
     }
 
-    @Test(enabled=true) public void deferedReload() throws IOException, InterruptedException {
+    @Test(enabled=true) public void deferedReload() throws IOException, InterruptedException, ComponentInitializationException {
         final ReloadableSpringService<TestServiceableComponent> service =
                 new ReloadableSpringService<>(TestServiceableComponent.class);
 
@@ -133,7 +133,7 @@ public class ReloadableSpringServiceTest {
         service.setReloadCheckDelay(RELOAD_DELAY);
         service.setServiceConfigurations(CollectionSupport.singletonList(testFileResource()));
 
-        service.start();
+        service.initialize();
 
         final TestServiceableComponent component;
         try (final ServiceableComponent<TestServiceableComponent> serviceableComponent = service.getServiceableComponent()) {
@@ -178,7 +178,7 @@ public class ReloadableSpringServiceTest {
             count--;
         }
         Assert.assertTrue(component.isDestroyed(), "After 7 second initial component has still not be destroyed");
-        service.stop();
+        service.destroy();
         deleteFile();
     }
 
@@ -194,9 +194,9 @@ public class ReloadableSpringServiceTest {
         service.setServiceConfigurations(CollectionSupport.singletonList(testFileResource()));
 
         try {
-            service.start();
+            service.initialize();
             Assert.fail("Expected to fail");
-        } catch (final BeanInitializationException e) {
+        } catch (final ComponentInitializationException e) {
             // OK
         }
         
@@ -218,10 +218,10 @@ public class ReloadableSpringServiceTest {
             // OK
         }
 
-        service.stop();
+        service.destroy();
         deleteFile();
     }
-    @Test public void testNotFailFast() throws IOException, InterruptedException {
+    @Test public void testNotFailFast() throws IOException, InterruptedException, ComponentInitializationException {
         final ReloadableSpringService<TestServiceableComponent> service =
                 new ReloadableSpringService<>(TestServiceableComponent.class);
 
@@ -232,7 +232,7 @@ public class ReloadableSpringServiceTest {
         service.setReloadCheckDelay(RELOAD_DELAY);
         service.setServiceConfigurations(CollectionSupport.singletonList(testFileResource()));
 
-        service.start();
+        service.initialize();
 
         try {
             service.getServiceableComponent();
@@ -260,7 +260,7 @@ public class ReloadableSpringServiceTest {
 
         Assert.assertFalse(component.isDestroyed());
         serviceableComponent.unpinComponent();
-        service.stop();
+        service.destroy();
 
         count = 70;
         while (count > 0 && !component.isDestroyed()) {

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


More information about the commits mailing list