[java-shib-shared] branch main updated: JSE-51 - Wildcard classpath imports don't work in our import logic

Scott Cantor cantor.2 at osu.edu
Fri Nov 18 14:42:57 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=20736667d80966378b9fae19c3d87c2617988043

The following commit(s) were added to refs/heads/main by this push:
     new 20736667 JSE-51 - Wildcard classpath imports don't work in our import logic
20736667 is described below

commit 20736667d80966378b9fae19c3d87c2617988043
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Fri Nov 18 09:42:54 2022 -0500

    JSE-51 - Wildcard classpath imports don't work in our import logic
    
    https://shibboleth.atlassian.net/browse/JSE-51
---
 .../custom/SchemaTypeAwareBeanDefinitionDocumentReader.java | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/shib-spring/src/main/java/net/shibboleth/shared/spring/custom/SchemaTypeAwareBeanDefinitionDocumentReader.java b/shib-spring/src/main/java/net/shibboleth/shared/spring/custom/SchemaTypeAwareBeanDefinitionDocumentReader.java
index 4f482e65..05f005bb 100644
--- a/shib-spring/src/main/java/net/shibboleth/shared/spring/custom/SchemaTypeAwareBeanDefinitionDocumentReader.java
+++ b/shib-spring/src/main/java/net/shibboleth/shared/spring/custom/SchemaTypeAwareBeanDefinitionDocumentReader.java
@@ -28,6 +28,7 @@ import org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader
 import org.springframework.beans.factory.xml.XmlReaderContext;
 import org.springframework.core.io.Resource;
 import org.springframework.core.io.ResourceLoader;
+import org.springframework.core.io.support.ResourcePatternResolver;
 import org.springframework.util.StringUtils;
 import org.w3c.dom.Element;
 
@@ -46,6 +47,9 @@ public class SchemaTypeAwareBeanDefinitionDocumentReader extends DefaultBeanDefi
      * 
      * This override prevents the default behavior from kicking in if the original resource location
      * is directly usable by the installed {@link ResourceLoader}.
+     * 
+     * <p>This is needed because Spring's internal behavior around imports unfortunately ignores the
+     * whole ResourceLoader hook. Arguably a bug.</p>
      */
     @Override
     protected void importBeanDefinitionResource(@Nonnull final Element ele) {
@@ -56,8 +60,16 @@ public class SchemaTypeAwareBeanDefinitionDocumentReader extends DefaultBeanDefi
         }
 
         // Resolve system properties: e.g. "${user.dir}"
+        assert location != null;
         location = getReaderContext().getEnvironment().resolveRequiredPlaceholders(location);
 
+        // Check for wildcard syntax we don't handle, JSE-51.
+        if (location.startsWith(ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX)) {
+            logger.debug("Wildcard classpath syntax, delegating to default behavior");
+            super.importBeanDefinitionResource(ele);
+            return;
+        }
+
         final Set<Resource> actualResources = new LinkedHashSet<>(4);
 
         final ResourceLoader loader = getReaderContext().getResourceLoader();
@@ -77,6 +89,7 @@ public class SchemaTypeAwareBeanDefinitionDocumentReader extends DefaultBeanDefi
                 logger.trace("Imported " + importCount + " bean definitions from location [" + location + "]");
             }
             final Resource[] actResArray = actualResources.toArray(new Resource[0]);
+            assert actResArray != null;
             getReaderContext().fireImportProcessed(location, actResArray, extractSource(ele));
         } else {
             logger.debug("Resource location [" + location + "] does not exist, delegating to default behavior");

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


More information about the commits mailing list