[java-shib-shared] branch main updated: Fix null and annotation bugs.

Scott Cantor cantor.2 at osu.edu
Mon Nov 7 16:28:01 UTC 2022


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

scantor pushed a commit to branch main
in repository java-shib-shared.

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

The following commit(s) were added to refs/heads/main by this push:
     new 6a9ff768 Fix null and annotation bugs.
6a9ff768 is described below

commit 6a9ff768884bc150730682bdeb778626f2db99e2
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Nov 7 11:27:58 2022 -0500

    Fix null and annotation bugs.
---
 .../shared/service/AbstractReloadableService.java  |  1 +
 .../shared/service/ReloadableServiceGaugeSet.java  |  6 +--
 .../shared/service/impl/LogbackLoggingService.java |  7 ++--
 .../service/reloadable/ProxiedFactoryBean.java     | 19 ++++-----
 .../shared/service/reloadable/ReloadableScope.java | 17 +++++---
 .../impl/ReloadingAccessControlService.java        |  9 ++--
 .../impl/ServiceableAccessControlService.java      |  9 ++--
 .../service/ApplicationContextServiceStrategy.java |  7 +++-
 .../spring/service/ClassBasedServiceStrategy.java  |  8 +++-
 .../spring/service/ReloadableSpringService.java    | 49 +++++++++++++---------
 .../spring/service/ReloadableBeanServiceTest.java  |  2 +
 .../service/ReloadableSpringServiceTest.java       | 39 +++++++++++------
 12 files changed, 107 insertions(+), 66 deletions(-)

diff --git a/shib-service/src/main/java/net/shibboleth/shared/service/AbstractReloadableService.java b/shib-service/src/main/java/net/shibboleth/shared/service/AbstractReloadableService.java
index 27ec7549..33f0bbc8 100644
--- a/shib-service/src/main/java/net/shibboleth/shared/service/AbstractReloadableService.java
+++ b/shib-service/src/main/java/net/shibboleth/shared/service/AbstractReloadableService.java
@@ -198,6 +198,7 @@ public abstract class AbstractReloadableService<T> extends AbstractIdentifiableI
             }
             log.info("{} Reload interval set to: {}, starting refresh thread", getLogPrefix(), reloadCheckDelay);
             reloadTask = new ServiceReloadTask();
+            assert(internalTaskTimer != null);
             internalTaskTimer.schedule(reloadTask, reloadCheckDelay.toMillis(), reloadCheckDelay.toMillis());
         }
     }
diff --git a/shib-service/src/main/java/net/shibboleth/shared/service/ReloadableServiceGaugeSet.java b/shib-service/src/main/java/net/shibboleth/shared/service/ReloadableServiceGaugeSet.java
index 1af196f5..2bd43569 100644
--- a/shib-service/src/main/java/net/shibboleth/shared/service/ReloadableServiceGaugeSet.java
+++ b/shib-service/src/main/java/net/shibboleth/shared/service/ReloadableServiceGaugeSet.java
@@ -45,7 +45,7 @@ import net.shibboleth.shared.logic.Constraint;
 public class ReloadableServiceGaugeSet<T> extends AbstractInitializableComponent implements MetricSet, MetricFilter {
 
     /** The map of gauges. */
-    @NonnullAfterInit @NonnullElements private Map<String,Metric> gauges;
+    @Nonnull @NonnullElements private Map<String,Metric> gauges;
     
     /** The service to report on. */
     @NonnullAfterInit private ReloadableService<T> service;
@@ -83,8 +83,8 @@ public class ReloadableServiceGaugeSet<T> extends AbstractInitializableComponent
                 MetricRegistry.name(metricPrefix, "reload", "error"),
                 new Gauge<String>() {
                     public String getValue() {
-                        return service.getReloadFailureCause() != null
-                                ? service.getReloadFailureCause().getMessage() : null;
+                        final Throwable cause = service.getReloadFailureCause();
+                        return cause != null ? cause.getMessage() : null;
                     }
                 });
 
diff --git a/shib-service/src/main/java/net/shibboleth/shared/service/impl/LogbackLoggingService.java b/shib-service/src/main/java/net/shibboleth/shared/service/impl/LogbackLoggingService.java
index 7e6e4158..24e0cd49 100644
--- a/shib-service/src/main/java/net/shibboleth/shared/service/impl/LogbackLoggingService.java
+++ b/shib-service/src/main/java/net/shibboleth/shared/service/impl/LogbackLoggingService.java
@@ -101,7 +101,7 @@ public class LogbackLoggingService extends AbstractReloadableService<Object>
     }
 
     /** {@inheritDoc} */
-    public void setApplicationContext(final ApplicationContext context) {
+    public void setApplicationContext(final @Nonnull ApplicationContext context) {
         applicationContext = context;
     }
 
@@ -230,8 +230,9 @@ public class LogbackLoggingService extends AbstractReloadableService<Object>
      * the logging configuration itself as a location.</p>
      */
     protected void loadHomeProperty() {
-        if (applicationContext != null && homePropertyName != null) {
-            final String home = applicationContext.getEnvironment().getProperty(homePropertyName);
+        final String homePropertyName2 = homePropertyName;
+        if (applicationContext != null && homePropertyName2 != null) {
+            final String home = applicationContext.getEnvironment().getProperty(homePropertyName2);
             if (home != null) {
                 statusManager.add(
                         new InfoStatus("Setting logger property '" + homePropertyName + "' to '" + home + "'", this));
diff --git a/shib-service/src/main/java/net/shibboleth/shared/service/reloadable/ProxiedFactoryBean.java b/shib-service/src/main/java/net/shibboleth/shared/service/reloadable/ProxiedFactoryBean.java
index dc81d4eb..9301bf77 100644
--- a/shib-service/src/main/java/net/shibboleth/shared/service/reloadable/ProxiedFactoryBean.java
+++ b/shib-service/src/main/java/net/shibboleth/shared/service/reloadable/ProxiedFactoryBean.java
@@ -110,26 +110,21 @@ public class ProxiedFactoryBean<T> extends AbstractFactoryBean<T> {
 
     /** {@inheritDoc} */
     @Override
-    protected T createInstance() throws Exception {
+    @Nonnull protected T createInstance() throws Exception {
         
         try (final ServiceableComponent<ApplicationContext> component = contextService.getServiceableComponent()) {
             if (component == null) {
                 throw new BeanCreationException("ApplicationContext not available");
             }
         
-            if (beanName != null) {
+            String name = beanName;
+            if (name != null) {
                 try {
-                    final T bean = component.getComponent().getBean(beanName, beanType); 
-                    if (bean != null) {
-                        return bean;
-                    } else if (backupName != null) {
-                        return component.getComponent().getBean(backupName, beanType);
-                    } else {
-                        return null;
-                    }
+                    return component.getComponent().getBean(name, beanType); 
                 } catch (final NoSuchBeanDefinitionException e) {
-                    if (backupName != null) {
-                        return component.getComponent().getBean(backupName, beanType);
+                    name = backupName;
+                    if (name != null) {
+                        return component.getComponent().getBean(name, beanType);
                     }
                     throw e;
                 }
diff --git a/shib-service/src/main/java/net/shibboleth/shared/service/reloadable/ReloadableScope.java b/shib-service/src/main/java/net/shibboleth/shared/service/reloadable/ReloadableScope.java
index 8e724d56..8440c984 100644
--- a/shib-service/src/main/java/net/shibboleth/shared/service/reloadable/ReloadableScope.java
+++ b/shib-service/src/main/java/net/shibboleth/shared/service/reloadable/ReloadableScope.java
@@ -18,6 +18,7 @@
 package net.shibboleth.shared.service.reloadable;
 
 import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
 
 import net.shibboleth.shared.annotation.ParameterName;
 import net.shibboleth.shared.annotation.constraint.NotEmpty;
@@ -58,30 +59,34 @@ public class ReloadableScope implements Scope {
     }
 
     /** {@inheritDoc} */
-    public Object get(final String name, final ObjectFactory<?> objectFactory) {
+    @Nonnull public Object get(@Nonnull final String name, @Nonnull final ObjectFactory<?> objectFactory) {
         log.debug("Accessing reloadable bean instance '{}'", name);
         try (final ServiceableComponent<ApplicationContext> component = reloadableService.getServiceableComponent()) {
-            return component.getComponent().getBean(name);
+            if (component != null) {
+                return component.getComponent().getBean(name);
+            } else {
+                throw new IllegalStateException("Reloadable bean context is unavailable");
+            }
         }
     }
 
     /** {@inheritDoc} */
-    public Object remove(final String name) {
+    public Object remove(@Nonnull final String name) {
         throw new UnsupportedOperationException("No support for object removal");
     }
 
     /** {@inheritDoc} */
-    public void registerDestructionCallback(final String name, final Runnable callback) {
+    public void registerDestructionCallback(@Nonnull final String name, @Nonnull final Runnable callback) {
         log.warn("Ignoring unsupported destruction callback for '{}'", name);
     }
 
     /** {@inheritDoc} */
-    public Object resolveContextualObject(final String key) {
+    @Nullable public Object resolveContextualObject(@Nonnull final String key) {
         return null;
     }
 
     /** {@inheritDoc} */
-    public String getConversationId() {
+    @Nullable public String getConversationId() {
         return null;
     }
 
diff --git a/shib-service/src/main/java/net/shibboleth/shared/service/security/impl/ReloadingAccessControlService.java b/shib-service/src/main/java/net/shibboleth/shared/service/security/impl/ReloadingAccessControlService.java
index 5de357ab..fe5917c3 100644
--- a/shib-service/src/main/java/net/shibboleth/shared/service/security/impl/ReloadingAccessControlService.java
+++ b/shib-service/src/main/java/net/shibboleth/shared/service/security/impl/ReloadingAccessControlService.java
@@ -48,19 +48,22 @@ public class ReloadingAccessControlService extends AbstractServiceableComponent<
     /** {@inheritDoc} */
     @Override
     protected void doInitialize() throws ComponentInitializationException {
-        setId(service.getId());
+        final String id = service.getId();
+        if (id != null) {
+            setId(id);
+        }
         super.doInitialize();
     }
 
     /** {@inheritDoc} */
     @Override
-    public AccessControl getInstance(@Nonnull final String name) {
+    @Nonnull public AccessControl getInstance(@Nonnull final String name) {
         return service.getInstance(name);
     }
 
     /** {@inheritDoc} */
     @Override
-    public AccessControlService getComponent() {
+    @Nonnull public AccessControlService getComponent() {
         return this;
     }
 
diff --git a/shib-service/src/main/java/net/shibboleth/shared/service/security/impl/ServiceableAccessControlService.java b/shib-service/src/main/java/net/shibboleth/shared/service/security/impl/ServiceableAccessControlService.java
index 5686d136..4f1afe70 100644
--- a/shib-service/src/main/java/net/shibboleth/shared/service/security/impl/ServiceableAccessControlService.java
+++ b/shib-service/src/main/java/net/shibboleth/shared/service/security/impl/ServiceableAccessControlService.java
@@ -48,19 +48,22 @@ public class ServiceableAccessControlService extends AbstractServiceableComponen
     /** {@inheritDoc} */
     @Override
     protected void doInitialize() throws ComponentInitializationException {
-        setId(service.getId());
+        final String id = service.getId();
+        if (id != null) {
+            setId(id);
+        }
         super.doInitialize();
     }
 
     /** {@inheritDoc} */
     @Override
-    public AccessControl getInstance(@Nonnull final String name) {
+    @Nonnull public AccessControl getInstance(@Nonnull final String name) {
         return service.getInstance(name);
     }
 
     /** {@inheritDoc} */
     @Override
-    public AccessControlService getComponent() {
+    @Nonnull public AccessControlService getComponent() {
         return this;
     }
     
diff --git a/shib-service/src/main/java/net/shibboleth/shared/spring/service/ApplicationContextServiceStrategy.java b/shib-service/src/main/java/net/shibboleth/shared/spring/service/ApplicationContextServiceStrategy.java
index db18ef16..cf1700b2 100644
--- a/shib-service/src/main/java/net/shibboleth/shared/spring/service/ApplicationContextServiceStrategy.java
+++ b/shib-service/src/main/java/net/shibboleth/shared/spring/service/ApplicationContextServiceStrategy.java
@@ -46,7 +46,12 @@ public class ApplicationContextServiceStrategy implements
         if (appContext != null) {
             final ApplicationContextServiceableComponent wrapper = new ApplicationContextServiceableComponent();
             wrapper.setApplicationContext(appContext);
-            wrapper.setId(appContext.getId());
+            final String id = appContext.getId();
+            if (id != null) {
+                wrapper.setId(id);
+            } else {
+                wrapper.setId(appContext.getApplicationName());
+            }
             try {
                 wrapper.initialize();
                 return wrapper;
diff --git a/shib-service/src/main/java/net/shibboleth/shared/spring/service/ClassBasedServiceStrategy.java b/shib-service/src/main/java/net/shibboleth/shared/spring/service/ClassBasedServiceStrategy.java
index 07fe075a..6bdafa17 100644
--- a/shib-service/src/main/java/net/shibboleth/shared/spring/service/ClassBasedServiceStrategy.java
+++ b/shib-service/src/main/java/net/shibboleth/shared/spring/service/ClassBasedServiceStrategy.java
@@ -59,8 +59,12 @@ public class ClassBasedServiceStrategy<T> implements Function<ApplicationContext
 
     /** {@inheritDoc} */
     @Nullable public AbstractServiceableComponent<T> apply(@Nullable final ApplicationContext appContext) {
-        final Collection<AbstractServiceableComponent> components =
-                appContext.getBeansOfType(serviceClaz).values();
+        
+        if (appContext == null) {
+            throw new ServiceException("Input ApplicationContext was null");
+        }
+        
+        final Collection<AbstractServiceableComponent> components = appContext.getBeansOfType(serviceClaz).values();
 
         if (components.size() == 0) {
             throw new ServiceException("Reload did not produce any bean of type " + serviceClaz.getName());
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 2bab9754..de28840f 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
@@ -178,7 +178,7 @@ public class ReloadableSpringService<T> extends AbstractReloadableService<T> imp
 
         serviceConfigurations = List.copyOf(Constraint.isNotNull(configs, "Service configurations cannot be null"));
         if (!serviceConfigurations.isEmpty()) {
-            resourceLastModifiedTimes = new Instant[serviceConfigurations.size()];
+            final Instant[] lastModifiedTimes = new Instant[serviceConfigurations.size()];
 
             final int numOfResources = serviceConfigurations.size();
             Resource serviceConfig;
@@ -186,16 +186,19 @@ public class ReloadableSpringService<T> extends AbstractReloadableService<T> imp
                 serviceConfig = serviceConfigurations.get(i);
                 try {
                     if (serviceConfig.exists()) {
-                        resourceLastModifiedTimes[i] = Instant.ofEpochMilli(serviceConfig.lastModified());
+                        lastModifiedTimes[i] = Instant.ofEpochMilli(serviceConfig.lastModified());
                     } else {
-                        resourceLastModifiedTimes[i] = null;
+                        lastModifiedTimes[i] = null;
                     }
                 } catch (final IOException e) {
                     log.info("{} Configuration resource '" + serviceConfig.getDescription()
                             + "' last modification date could not be determined", getLogPrefix(), e);
-                    resourceLastModifiedTimes[i] = null;
+                    lastModifiedTimes[i] = null;
                 }
             }
+            
+            resourceLastModifiedTimes = lastModifiedTimes;
+            
         } else {
             resourceLastModifiedTimes = null;
         }
@@ -296,7 +299,9 @@ public class ReloadableSpringService<T> extends AbstractReloadableService<T> imp
         // requires the write lock, and the only post-initialization code that reads or writes
         // the array of resource mod-time data is this code, which is on one thread.
 
-        if (resourceLastModifiedTimes == null) {
+        final Instant[] lastModifiedTimes = resourceLastModifiedTimes;
+        
+        if (lastModifiedTimes == null) {
             return false;
         }
 
@@ -312,29 +317,29 @@ public class ReloadableSpringService<T> extends AbstractReloadableService<T> imp
         for (int i = 0; i < numOfResources; i++) {
             serviceConfig = serviceConfigurations.get(i);
             try {
-                if (resourceLastModifiedTimes[i] == null && !serviceConfig.exists()) {
+                if (lastModifiedTimes[i] == null && !serviceConfig.exists()) {
                     // Resource did not exist and still does not exist.
                     log.debug("{} Resource remains unavailable/inaccessible: '{}'", getLogPrefix(),
                             serviceConfig.getDescription());
-                } else if (resourceLastModifiedTimes[i] == null && serviceConfig.exists()) {
+                } else if (lastModifiedTimes[i] == null && serviceConfig.exists()) {
                     // Resource did not exist, but does now.
                     log.debug("{} Resource was unavailable, now present: '{}'", getLogPrefix(),
                             serviceConfig.getDescription());
                     configResourceChanged = true;
-                    resourceLastModifiedTimes[i] = Instant.ofEpochMilli(serviceConfig.lastModified());
-                } else if (resourceLastModifiedTimes[i] != null && !serviceConfig.exists()) {
+                    lastModifiedTimes[i] = Instant.ofEpochMilli(serviceConfig.lastModified());
+                } else if (lastModifiedTimes[i] != null && !serviceConfig.exists()) {
                     // Resource existed, but is now unavailable.
                     log.debug("{} Resource was available, now is not: '{}'", getLogPrefix(),
                             serviceConfig.getDescription());
                     configResourceChanged = true;
-                    resourceLastModifiedTimes[i] = null;
+                    lastModifiedTimes[i] = null;
                 } else {
                     // Check to see if an existing resource, that still exists, has been modified.
                     serviceConfigLastModified = Instant.ofEpochMilli(serviceConfig.lastModified());
-                    if (!serviceConfigLastModified.equals(resourceLastModifiedTimes[i])) {
+                    if (!serviceConfigLastModified.equals(lastModifiedTimes[i])) {
                         log.debug("{} Resource has changed: '{}'", getLogPrefix(), serviceConfig.getDescription());
                         configResourceChanged = true;
-                        resourceLastModifiedTimes[i] = serviceConfigLastModified;
+                        lastModifiedTimes[i] = serviceConfigLastModified;
                     } else {
                         log.trace("{} Resource has not changed '{}'", getLogPrefix(), serviceConfig.getDescription());
                     }
@@ -345,7 +350,8 @@ public class ReloadableSpringService<T> extends AbstractReloadableService<T> imp
                 configResourceChanged = true;
             }
         }
-
+        
+        resourceLastModifiedTimes = lastModifiedTimes;
         return configResourceChanged;
     }
 // Checkstyle: CyclomaticComplexity ON
@@ -440,26 +446,29 @@ public class ReloadableSpringService<T> extends AbstractReloadableService<T> imp
      * 
      * @return the <em>pinned</em> component.
      */
-    @Override public synchronized AbstractServiceableComponent<T> getServiceableComponent() {
-        if (null == cachedComponent) {
-            return null;
+    @Override
+    @Nullable public synchronized AbstractServiceableComponent<T> getServiceableComponent() {
+        if (null != cachedComponent) {
+            cachedComponent.pinComponent();
+            
         }
-        cachedComponent.pinComponent();
+        
         return cachedComponent;
     }
 
     /** {@inheritDoc} */
-    public void setApplicationContext(final ApplicationContext applicationContext) {
+    public void setApplicationContext(@Nonnull final ApplicationContext applicationContext) {
         setParentContext(applicationContext);
     }
 
     /** {@inheritDoc} */
-    public void setBeanName(final String name) {
+    public void setBeanName(@Nonnull final String name) {
         beanName = name;
     }
 
     /** {@inheritDoc} */
-    @Override protected void doInitialize() throws ComponentInitializationException {        
+    @Override
+    protected void doInitialize() throws ComponentInitializationException {        
         if (getId() == null && beanName != null) {
             setId(beanName);
         }
diff --git a/shib-service/src/test/java/net/shibboleth/shared/spring/service/ReloadableBeanServiceTest.java b/shib-service/src/test/java/net/shibboleth/shared/spring/service/ReloadableBeanServiceTest.java
index ca224a47..9870e0ed 100644
--- a/shib-service/src/test/java/net/shibboleth/shared/spring/service/ReloadableBeanServiceTest.java
+++ b/shib-service/src/test/java/net/shibboleth/shared/spring/service/ReloadableBeanServiceTest.java
@@ -31,6 +31,7 @@ import org.springframework.core.io.Resource;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
+ at SuppressWarnings("javadoc")
 public class ReloadableBeanServiceTest {
 
     @Test public void reloadableService() throws IOException, InterruptedException {
@@ -49,6 +50,7 @@ public class ReloadableBeanServiceTest {
                     appCtx.getBean("reloadableBeanService", ReloadableService.class);
             
             try (final ServiceableComponent<ApplicationContext> component = embedded.getServiceableComponent()) {
+                assert(component != null);
                 Assert.assertFalse(component.getComponent().containsLocalBean("reloadableBeanService"));
             }
             
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 a44e0540..591406f2 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,6 +25,9 @@ import java.time.Duration;
 import java.time.Instant;
 import java.util.Collections;
 
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
 import net.shibboleth.shared.service.ServiceableComponent;
 import net.shibboleth.shared.spring.util.ApplicationContextBuilder;
 
@@ -43,25 +46,30 @@ import com.google.common.io.ByteStreams;
 @SuppressWarnings("javadoc")
 public class ReloadableSpringServiceTest {
 
-    private static final Duration RELOAD_DELAY = Duration.ofMillis(100);
+    @Nonnull private static final Duration RELOAD_DELAY = Duration.ofMillis(100);
 
-    private File testFile;
+    @Nullable private File testFile;
 
-    private void createPopulatedFile(final String dataPath) throws IOException {
+    private void createPopulatedFile(@Nonnull final String dataPath) throws IOException {
         testFile = File.createTempFile("ReloadableSpringServiceTest", ".xml");
         overwriteFileWith(dataPath);
-        testFile.setLastModified(365*24*60*60*1000);
+        if (testFile != null) {
+            testFile.setLastModified(365*24*60*60*1000);
+        }
     }
     
-    @AfterMethod public void  deleteFile() {
-        if (null != testFile) {
-            if (testFile.exists()) {
-                testFile.delete();
+    @AfterMethod public void deleteFile() {
+        final File file = testFile;
+        if (null != file) {
+            if (file.exists()) {
+                file.delete();
             }
+            testFile = null;
         }
     }
 
-    private Resource testFileResource() {
+    @Nonnull private Resource testFileResource() {
+        assert(testFile != null);
         return new FileSystemResource(testFile);
     }
 
@@ -85,6 +93,7 @@ public class ReloadableSpringServiceTest {
         service.start();
 
         AbstractServiceableComponent<TestServiceableComponent> serviceableComponent = service.getServiceableComponent();
+        assert(serviceableComponent != null);
         final TestServiceableComponent component = serviceableComponent.getComponent();
 
         Assert.assertEquals("One", component.getTheValue());
@@ -106,12 +115,13 @@ public class ReloadableSpringServiceTest {
         Assert.assertTrue(serviceableComponent.getComponent().isDestroyed());
 
         serviceableComponent = service.getServiceableComponent();
+        assert(serviceableComponent != null);
 
         Assert.assertEquals(serviceableComponent.getComponent().getTheValue(), "Two");
         serviceableComponent.unpinComponent();
         service.stop();
         
-        testFile.delete();
+        deleteFile();
     }
 
     @Test(enabled=true) public void deferedReload() throws IOException, InterruptedException {
@@ -128,6 +138,7 @@ public class ReloadableSpringServiceTest {
         service.start();
 
         ServiceableComponent<TestServiceableComponent> serviceableComponent = service.getServiceableComponent();
+        assert(serviceableComponent != null);
         final TestServiceableComponent component = serviceableComponent.getComponent();
         
         final Instant x = service.getLastReloadAttemptInstant();
@@ -150,6 +161,7 @@ public class ReloadableSpringServiceTest {
         TestServiceableComponent component2 = null;
         while (count > 0) {
             serviceableComponent = service.getServiceableComponent();
+            assert(serviceableComponent != null);
             component2 = serviceableComponent.getComponent();
             if ("Two".equals(component2.getTheValue())) {
                 component2.unpinComponent();
@@ -172,7 +184,7 @@ public class ReloadableSpringServiceTest {
         Assert.assertTrue(component.isDestroyed(), "After 7 second initial component has still not be destroyed");
 
         service.stop();
-        testFile.delete();
+        deleteFile();
     }
 
     @Test public void testFailFast() throws IOException, InterruptedException {
@@ -200,7 +212,7 @@ public class ReloadableSpringServiceTest {
         Assert.assertNull(service.getServiceableComponent());
 
         service.stop();
-        testFile.delete();
+        deleteFile();
     }
 
     @Test public void testNotFailFast() throws IOException, InterruptedException {
@@ -227,6 +239,7 @@ public class ReloadableSpringServiceTest {
             serviceableComponent = service.getServiceableComponent();
         }
         Assert.assertNotNull(serviceableComponent, "After 7 second component has still no initialized");
+        assert(serviceableComponent != null);
         final TestServiceableComponent component = serviceableComponent.getComponent();
         Assert.assertEquals(component.getTheValue(), "Two");
 
@@ -241,7 +254,7 @@ public class ReloadableSpringServiceTest {
         }
         Assert.assertTrue(component.isDestroyed(), "After 7 seconds component has still not be destroyed");
 
-        testFile.delete();
+        deleteFile();
     }
 
     @Test public void testApplicationContextAware() {

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


More information about the commits mailing list