[spring-extensions] branch main updated: IDP-1833 - Wildcard classpath breaks inside flow imports on Windows

Scott Cantor cantor.2 at osu.edu
Mon Jul 19 13:58:42 UTC 2021


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

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

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

The following commit(s) were added to refs/heads/main by this push:
       new  36edeb8   IDP-1833 - Wildcard classpath breaks inside flow imports on Windows
36edeb8 is described below

commit 36edeb8a549b72049f788a14f57bdfe508c5ef79
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Jul 19 09:58:39 2021 -0400

    IDP-1833 - Wildcard classpath breaks inside flow imports on Windows
    
    https://issues.shibboleth.net/jira/browse/IDP-1833
    
    Guard exception paths around exists calls.
---
 .../context/FileSystemXmlWebApplicationContext.java     | 10 +++++++---
 .../context/FilesystemGenericApplicationContext.java    | 10 +++++++---
 .../context/FilesystemGenericWebApplicationContext.java | 10 +++++++---
 .../ext/spring/resource/ConditionalResource.java        |  8 ++++++--
 .../SchemaTypeAwareBeanDefinitionDocumentReader.java    | 17 ++++++++++++-----
 5 files changed, 39 insertions(+), 16 deletions(-)

diff --git a/src/main/java/net/shibboleth/ext/spring/context/FileSystemXmlWebApplicationContext.java b/src/main/java/net/shibboleth/ext/spring/context/FileSystemXmlWebApplicationContext.java
index 1ee4104..de3a0dd 100644
--- a/src/main/java/net/shibboleth/ext/spring/context/FileSystemXmlWebApplicationContext.java
+++ b/src/main/java/net/shibboleth/ext/spring/context/FileSystemXmlWebApplicationContext.java
@@ -50,9 +50,13 @@ public class FileSystemXmlWebApplicationContext extends XmlWebApplicationContext
      * </p>
      */
     @Override protected Resource getResourceByPath(final String path) {
-        final Resource r = new FileSystemResource(path);
-        if (r.exists()) {
-            return r;
+        try {
+            final Resource r = new FileSystemResource(path);
+            if (r.exists()) {
+                return r;
+            }
+        } catch (final Exception e) {
+            // May happen if resource wrapper throws during exists() call.
         }
         return super.getResourceByPath(path);
     }
diff --git a/src/main/java/net/shibboleth/ext/spring/context/FilesystemGenericApplicationContext.java b/src/main/java/net/shibboleth/ext/spring/context/FilesystemGenericApplicationContext.java
index 090c6b7..4056912 100644
--- a/src/main/java/net/shibboleth/ext/spring/context/FilesystemGenericApplicationContext.java
+++ b/src/main/java/net/shibboleth/ext/spring/context/FilesystemGenericApplicationContext.java
@@ -83,9 +83,13 @@ public class FilesystemGenericApplicationContext extends GenericApplicationConte
      * </p>
      */
     @Override protected Resource getResourceByPath(final String path) {
-        final Resource r = new FileSystemResource(path);
-        if (r.exists()) {
-            return r;
+        try {
+            final Resource r = new FileSystemResource(path);
+            if (r.exists()) {
+                return r;
+            }
+        } catch (final Exception e) {
+            // May happen if resource wrapper throws during exists() call.
         }
         return super.getResourceByPath(path);
     }
diff --git a/src/main/java/net/shibboleth/ext/spring/context/FilesystemGenericWebApplicationContext.java b/src/main/java/net/shibboleth/ext/spring/context/FilesystemGenericWebApplicationContext.java
index 17a6ce2..2ce9fff 100644
--- a/src/main/java/net/shibboleth/ext/spring/context/FilesystemGenericWebApplicationContext.java
+++ b/src/main/java/net/shibboleth/ext/spring/context/FilesystemGenericWebApplicationContext.java
@@ -86,9 +86,13 @@ public class FilesystemGenericWebApplicationContext extends GenericWebApplicatio
      * </p>
      */
     @Override protected Resource getResourceByPath(final String path) {
-        final Resource r = new FileSystemResource(path);
-        if (r.exists()) {
-            return r;
+        try {
+            final Resource r = new FileSystemResource(path);
+            if (r.exists()) {
+                return r;
+            }
+        } catch (final Exception e) {
+            // May happen if resource wrapper throws during exists() call.
         }
         return super.getResourceByPath(path);
     }
diff --git a/src/main/java/net/shibboleth/ext/spring/resource/ConditionalResource.java b/src/main/java/net/shibboleth/ext/spring/resource/ConditionalResource.java
index c6e5807..263ca33 100644
--- a/src/main/java/net/shibboleth/ext/spring/resource/ConditionalResource.java
+++ b/src/main/java/net/shibboleth/ext/spring/resource/ConditionalResource.java
@@ -134,8 +134,12 @@ public class ConditionalResource extends AbstractIdentifiedInitializableComponen
     public boolean exists() {
         ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
         
-        if (!wrappedResource.exists()) {
-            log.debug("{} Wrapped resource does not exist", getLogPrefix());
+        try {
+            if (!wrappedResource.exists()) {
+                log.debug("{} Wrapped resource does not exist", getLogPrefix());
+            }
+        } catch (final Exception e) {
+            log.debug("{} Wrapped resource does not exist", getLogPrefix(), e);
         }
         return true;
     }
diff --git a/src/main/java/net/shibboleth/ext/spring/util/SchemaTypeAwareBeanDefinitionDocumentReader.java b/src/main/java/net/shibboleth/ext/spring/util/SchemaTypeAwareBeanDefinitionDocumentReader.java
index d44967a..f0164c4 100644
--- a/src/main/java/net/shibboleth/ext/spring/util/SchemaTypeAwareBeanDefinitionDocumentReader.java
+++ b/src/main/java/net/shibboleth/ext/spring/util/SchemaTypeAwareBeanDefinitionDocumentReader.java
@@ -58,7 +58,15 @@ public class SchemaTypeAwareBeanDefinitionDocumentReader extends DefaultBeanDefi
         final Set<Resource> actualResources = new LinkedHashSet<>(4);
 
         final Resource r = getReaderContext().getResourceLoader().getResource(location);
-        if (r.exists()) {
+        
+        boolean exists = false;
+        try {
+            exists = r.exists();
+        } catch (final Exception e) {
+            // In case exists() throws.
+        }
+        
+        if (exists) {
             final int importCount = getReaderContext().getReader().loadBeanDefinitions(r);
             actualResources.add(r);
             if (logger.isTraceEnabled()) {
@@ -66,11 +74,10 @@ public class SchemaTypeAwareBeanDefinitionDocumentReader extends DefaultBeanDefi
             }
             final Resource[] actResArray = actualResources.toArray(new Resource[0]);
             getReaderContext().fireImportProcessed(location, actResArray, extractSource(ele));
-            return;
+        } else {
+            logger.debug("Resource location [" + location + "] does not exist, delegating to default behavior");
+            super.importBeanDefinitionResource(ele);
         }
-        
-        logger.debug("Resource location [" + location + "] does not exist, delegating to default behavior");
-        super.importBeanDefinitionResource(ele);
     }
 
     /** {@inheritDoc} */

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


More information about the commits mailing list