clarified Resource's "getFilename" method to consistently return null if resource type does not have a filename (SPR-9043)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -150,11 +150,11 @@ public abstract class AbstractResource implements Resource {
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation always throws IllegalStateException,
|
||||
* assuming that the resource does not have a filename.
|
||||
* This implementation always returns <code>null</code>,
|
||||
* assuming that this resource type does not have a filename.
|
||||
*/
|
||||
public String getFilename() throws IllegalStateException {
|
||||
throw new IllegalStateException(getDescription() + " does not have a filename");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -116,8 +116,10 @@ public interface Resource extends InputStreamSource {
|
||||
Resource createRelative(String relativePath) throws IOException;
|
||||
|
||||
/**
|
||||
* Return a filename for this resource, i.e. typically the last
|
||||
* Determine a filename for this resource, i.e. typically the last
|
||||
* part of the path: for example, "myfile.txt".
|
||||
* <p>Returns <code>null</code> if this type of resource does not
|
||||
* have a filename.
|
||||
*/
|
||||
String getFilename();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,7 +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,9 +179,7 @@ public abstract class PropertiesLoaderSupport {
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = location.getInputStream();
|
||||
|
||||
String filename = (location instanceof AbstractFileResolvingResource) ?
|
||||
location.getFilename() : null;
|
||||
String filename = location.getFilename();
|
||||
if (filename != null && filename.endsWith(XML_FILE_EXTENSION)) {
|
||||
this.propertiesPersister.loadFromXml(props, is);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user