Skip to content

.properties should be encoded in ISO-8859-1 #5361

Closed
@jsiebahn

Description

@jsiebahn

By default Java .properties files are encoded in ISO-8859-1 (see https://en.wikipedia.org/wiki/.properties ) but since #4622 Spring-Boot reads them as UTF-8.

This causes incompatibility with Java and Spring itself.

The differences to Spring are very uncomfortable when it comes to unit tests, e.g. when the test case has its own Spring Context, .properties files are loaded by Spring and not by Spring Boot. They are parsed correctly as ISO-8859-1. But when the application is started, the same .properties are loaded by Spring-Boot and valid ISO-8859-1 characters are broken.

A JUnit test configured like this:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = MyTestConfig.class)
public class MyTest {
    // ...
}

with a test config importing a PropertySource:

@Configuration
@PropertySource(value = "/application.properties")
public class MyTestConfig {
}

will pass with ISO-8859-1 characters like "äöü" in the application.properties but the Spring-Boot application itself will show corrupted UTF-8 characters.

Furthermore the typical Java IDEs treat .properties files by default as ISO-8859-1 (or similar CP1252).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions