Browse Source

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
pull/1/head
Chris Beams 15 years ago
parent
commit
e78ced16b1
  1. 15
      org.springframework.core/src/main/java/org/springframework/core/io/support/PropertiesLoaderSupport.java

15
org.springframework.core/src/main/java/org/springframework/core/io/support/PropertiesLoaderSupport.java

@ -23,6 +23,7 @@ import java.util.Properties; @@ -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 { @@ -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) {

Loading…
Cancel
Save