Skip to content

PropertiesLoaderSupport no longer works with XML-formatted property files when they're loaded as a FileSystemResource. [SPR-9043] #13683

@spring-projects-issues

Description

@spring-projects-issues

matt opened SPR-9043 and commented

In Spring 3.0.6, when detecting whether a property file was a Java 5 xml-formatted property file, the code looked like this:


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);
}

In Spring 3.1, that code looks like this:

String filename = (location instanceof AbstractFileResolvingResource) ?
		location.getFilename() : null;
if (filename != null && filename.endsWith(XML_FILE_EXTENSION)) {
	this.propertiesPersister.loadFromXml(props, is);
}

The problem is, FileSystemResource doesn't extend AbstractFileResolvingResource. So if an xml-formatted properties file is loaded as a FileSystemResource, it will not be loaded properly.
I don't know if the right answer is to make FileSystemResource extend AbstractFileResolvingResource (which seems to make sense) or to change the "location instanceof AbstractFileResolvingResource" above to catch both cases -- AbstractFileResolvingResource or FileSystemResource.


Affects: 3.1 GA

Referenced from: commits 57851de, 1d9d3e6

1 votes, 2 watchers

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions