From e78ced16b11fd81a9753f137eae3278c26b90d1c Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Wed, 15 Dec 2010 17:09:31 +0000 Subject: [PATCH] Improved fix for detecting non-file based Resources in PropertiesLoaderSupport (SPR-7547, SPR-7552) Use instanceof check against AbstractFileResolvingResource instead of try/catch around resource.getFilename() call. git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3815 50f2f4bb-b051-0410-bef5-90022cba6387 --- .../core/io/support/PropertiesLoaderSupport.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/org.springframework.core/src/main/java/org/springframework/core/io/support/PropertiesLoaderSupport.java b/org.springframework.core/src/main/java/org/springframework/core/io/support/PropertiesLoaderSupport.java index e9289eed593..97b37690d4f 100644 --- a/org.springframework.core/src/main/java/org/springframework/core/io/support/PropertiesLoaderSupport.java +++ b/org.springframework.core/src/main/java/org/springframework/core/io/support/PropertiesLoaderSupport.java @@ -23,6 +23,7 @@ import java.util.Properties; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.core.io.AbstractFileResolvingResource; import org.springframework.core.io.Resource; import org.springframework.util.CollectionUtils; import org.springframework.util.DefaultPropertiesPersister; @@ -179,15 +180,11 @@ public abstract class PropertiesLoaderSupport { try { is = location.getInputStream(); - String filename = null; - try { - filename = location.getFilename(); - } catch (IllegalStateException ex) { - // resource is not file-based. See SPR-7552. - } - - if (filename != null && filename.endsWith(XML_FILE_EXTENSION)) { - this.propertiesPersister.loadFromXml(props, is); + if (location instanceof AbstractFileResolvingResource) { + String filename = location.getFilename(); + if (filename != null && filename.endsWith(XML_FILE_EXTENSION)) { + this.propertiesPersister.loadFromXml(props, is); + } } else { if (this.fileEncoding != null) {