Closed
Description
Fyro opened SPR-13874 and commented
It seems that there is not currently support for encoding/charset in @PropertySource("classpath:/...")
.
With french characters like "Générales", current result is "Générales" because there is no check with charset/encoding.
Default constructor with default charset, it's ok.
public EncodedResource(Resource resource) {
this(resource, null, Charset.defaultCharset());
}
Used in ConfigurationClassParser#processPropertySource
/**
* Create a PropertySource having the given name based on Properties
* loaded from the given encoded resource.
*/
public ResourcePropertySource(String name, Resource resource) throws IOException {
super(name, PropertiesLoaderUtils.loadProperties(new EncodedResource(resource)));
this.resourceName = getNameForResource(resource);
}
/**
* Create a PropertySource based on Properties loaded from the given resource.
* The name of the PropertySource will be generated based on the
* {@link Resource#getDescription() description} of the given resource.
*/
public ResourcePropertySource(Resource resource) throws IOException {
super(getNameForResource(resource), PropertiesLoaderUtils.loadProperties(new EncodedResource(resource)));
this.resourceName = null;
}
Affects: 4.2.4
Issue Links:
- Allow the use of custom PropertySource annotations in @Configuration classes [SPR-8963] #13603 Allow the use of custom PropertySource annotations in
@Configuration
classes - ResourcePropertySource class should support to specify character encoding [SPR-13881] #18454 ResourcePropertySource class should support to specify character encoding
Referenced from: commits a3a5a03