[spring-extensions] branch master updated: Code cleanup.

Scott Cantor cantor.2 at osu.edu
Wed Dec 28 20:46:43 EST 2016


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

scantor pushed a commit to branch master
in repository spring-extensions.

View the commit online:
http://git.shibboleth.net/view/?p=spring-extensions.git;a=commit;h=07707f3695d04aef1a3654cdbb72cdbb76bae4b0

The following commit(s) were added to refs/heads/master by this push:
       new  07707f3   Code cleanup.
07707f3 is described below

commit 07707f3695d04aef1a3654cdbb72cdbb76bae4b0
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Dec 28 20:46:39 2016 -0500

    Code cleanup.
---
 .../ext/spring/config/BooleanToPredicateConverter.java        |  4 ++--
 .../ext/spring/config/StringBooleanToPredicateConverter.java  |  4 ++--
 .../ext/spring/service/ReloadableSpringService.java           |  6 +++---
 .../java/net/shibboleth/ext/spring/util/SpringSupport.java    |  3 +++
 .../ext/spring/resource/FileBackedHTTPResourceTest.java       | 11 ++---------
 5 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/src/main/java/net/shibboleth/ext/spring/config/BooleanToPredicateConverter.java b/src/main/java/net/shibboleth/ext/spring/config/BooleanToPredicateConverter.java
index 7cac796..cc289ed 100644
--- a/src/main/java/net/shibboleth/ext/spring/config/BooleanToPredicateConverter.java
+++ b/src/main/java/net/shibboleth/ext/spring/config/BooleanToPredicateConverter.java
@@ -25,10 +25,10 @@ import com.google.common.base.Predicates;
 /**
  * Allows setting of fixed {@link Predicate} properties using a boolean value.
  */
-public class BooleanToPredicateConverter implements Converter<Boolean,Predicate> {
+public class BooleanToPredicateConverter implements Converter<Boolean,Predicate<?>> {
 
     /** {@inheritDoc} */
-    @Override public Predicate convert(final Boolean source) {
+    @Override public Predicate<?> convert(final Boolean source) {
         return source ? Predicates.alwaysTrue() : Predicates.alwaysFalse();
     }
     
diff --git a/src/main/java/net/shibboleth/ext/spring/config/StringBooleanToPredicateConverter.java b/src/main/java/net/shibboleth/ext/spring/config/StringBooleanToPredicateConverter.java
index 201af0b..e189b7d 100644
--- a/src/main/java/net/shibboleth/ext/spring/config/StringBooleanToPredicateConverter.java
+++ b/src/main/java/net/shibboleth/ext/spring/config/StringBooleanToPredicateConverter.java
@@ -31,13 +31,13 @@ import com.google.common.base.Predicates;
 /**
  * Allows setting of fixed {@link Predicate} properties using a boolean string.
  */
-public class StringBooleanToPredicateConverter implements Converter<String,Predicate> {
+public class StringBooleanToPredicateConverter implements Converter<String,Predicate<?>> {
 
     /** Logger. */
     @Nonnull private final Logger log = LoggerFactory.getLogger(StringBooleanToPredicateConverter.class);
 
     /** {@inheritDoc} */
-    @Override public Predicate convert(final String source) {
+    @Override public Predicate<?> convert(final String source) {
         
         final String trimmed = StringSupport.trimOrNull(source);
         if (Boolean.valueOf(trimmed)) {
diff --git a/src/main/java/net/shibboleth/ext/spring/service/ReloadableSpringService.java b/src/main/java/net/shibboleth/ext/spring/service/ReloadableSpringService.java
index 000ff08..20d9eb1 100644
--- a/src/main/java/net/shibboleth/ext/spring/service/ReloadableSpringService.java
+++ b/src/main/java/net/shibboleth/ext/spring/service/ReloadableSpringService.java
@@ -87,7 +87,7 @@ public class ReloadableSpringService<T> extends AbstractReloadableService<T> imp
     @Nonnull private final Class<T> theClaz;
 
     /** How to summon up the {@link ServiceableComponent} from the {@link ApplicationContext}. */
-    @Nonnull private final Function<GenericApplicationContext, ServiceableComponent> serviceStrategy;
+    @Nonnull private final Function<ApplicationContext, ServiceableComponent<T>> serviceStrategy;
 
     /** Application context owning this engine. */
     @Nullable private ApplicationContext parentContext;
@@ -113,7 +113,7 @@ public class ReloadableSpringService<T> extends AbstractReloadableService<T> imp
      * @param claz The interface being implemented.
      */
     public ReloadableSpringService(@Nonnull @ParameterName(name="claz") final Class<T> claz) {
-        this(claz, new ClassBasedServiceStrategy());
+        this(claz, new ClassBasedServiceStrategy<T>());
     }
 
     /**
@@ -124,7 +124,7 @@ public class ReloadableSpringService<T> extends AbstractReloadableService<T> imp
      */
     public ReloadableSpringService(@Nonnull @ParameterName(name="claz") final Class<T> claz,
              @Nonnull @ParameterName(name="strategy")
-                      final Function<GenericApplicationContext, ServiceableComponent> strategy) {
+                final Function<ApplicationContext,ServiceableComponent<T>> strategy) {
         theClaz = Constraint.isNotNull(claz, "Class cannot be null");
         serviceStrategy = Constraint.isNotNull(strategy, "Strategy cannot be null");
         factoryPostProcessors = Collections.emptyList();
diff --git a/src/main/java/net/shibboleth/ext/spring/util/SpringSupport.java b/src/main/java/net/shibboleth/ext/spring/util/SpringSupport.java
index 26cee05..553d34c 100644
--- a/src/main/java/net/shibboleth/ext/spring/util/SpringSupport.java
+++ b/src/main/java/net/shibboleth/ext/spring/util/SpringSupport.java
@@ -93,6 +93,9 @@ public final class SpringSupport {
      * @param parentContext parent context, or null if there is no parent
      * 
      * @return the created context
+     * 
+     * TODO: The signature here needs to constrain the ApplicationContextInitializers supplied to
+     * be safe for use with a FilesystemGenericApplicationContext. The raw types are masking the bug. 
      */
     @Nonnull public static GenericApplicationContext newContext(@Nonnull @NotEmpty final String name,
             @Nonnull @NonnullElements final List<Resource> configurationResources,
diff --git a/src/test/java/net/shibboleth/ext/spring/resource/FileBackedHTTPResourceTest.java b/src/test/java/net/shibboleth/ext/spring/resource/FileBackedHTTPResourceTest.java
index 0b7245b..6b57d45 100644
--- a/src/test/java/net/shibboleth/ext/spring/resource/FileBackedHTTPResourceTest.java
+++ b/src/test/java/net/shibboleth/ext/spring/resource/FileBackedHTTPResourceTest.java
@@ -118,9 +118,7 @@ public class FileBackedHTTPResourceTest {
 
     @Test public void testParsingOld() throws IOException {
 
-        final GenericApplicationContext context = getContext("net/shibboleth/ext/spring/resource/oldStyle.xml");
-
-        try {
+        try (final GenericApplicationContext context = getContext("net/shibboleth/ext/spring/resource/oldStyle.xml")) {
 
             Assert.assertTrue(ResourceTestHelper.compare(context.getBean("namedString", FileBackedHTTPResource.class),
                     new ClassPathResource("net/shibboleth/ext/spring/resource/document.xml")));
@@ -134,15 +132,12 @@ public class FileBackedHTTPResourceTest {
             Assert.assertTrue(ResourceTestHelper.compare(context.getBean("numberedURL", FileBackedHTTPResource.class),
                     new ClassPathResource("net/shibboleth/ext/spring/resource/document.xml")));
 
-        } finally {
-            context.close();
         }
     }
 
     @Test public void testParsingNew() throws IOException {
 
-        final GenericApplicationContext context = getContext("net/shibboleth/ext/spring/resource/newStyle.xml");
-        try {
+        try (final GenericApplicationContext context = getContext("net/shibboleth/ext/spring/resource/newStyle.xml")) {
 
             Assert.assertTrue(ResourceTestHelper.compare(context.getBean("namedString", FileBackedHTTPResource.class),
                     new ClassPathResource("net/shibboleth/ext/spring/resource/document.xml")));
@@ -153,8 +148,6 @@ public class FileBackedHTTPResourceTest {
                     new ClassPathResource("net/shibboleth/ext/spring/resource/document.xml")));
             Assert.assertTrue(ResourceTestHelper.compare(context.getBean("numberedURL", FileBackedHTTPResource.class),
                     new ClassPathResource("net/shibboleth/ext/spring/resource/document.xml")));
-        } finally {
-            context.close();
         }
     }
 

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


More information about the commits mailing list