I have map in application.properties , it uses non-latin characters. After populating them to map they have broken encoding. So I put annotation @PropertySource(value ="classpath:application.properties", encoding = "UTF-8"). After that, all values that have non-latin characters duplicates. So if you have two entries, one ascii and one utf-8 you will get map of 3 elements:

  1. ascii
  2. non-latin broken
  3. non-latin correct

Expected behavior 1. ascii 2. non-latin correct

Map example:

## map
app.brokenmap[файл]=val1
app.brokenmap[file]=val2
// Configuration properties
@Data
@PropertySource(value ="classpath:application.properties" ,encoding = "UTF-8")
@Configuration
@ConfigurationProperties(prefix = "app")
public class AppConfig {
    private Map<String, String> badmap = new LinkedHashMap<>();
}

// Test
@SpringBootTest(classes = { AppConfigTest.TestConfiguration.class })
class AppConfigTest {

    @Autowired
    private AppConfig config;

    @Test
    public void shouldInitiateProperties() {
        System.out.println(config.getFilesToTablesMap().size());
        config.getFilesToTablesMap().forEach(
                (name, table) -> System.out.println(String.format("%s %s", name, table))
        );
    }

    @EnableConfigurationProperties(AppConfig.class)
    public static class TestConfiguration {

    }

}

// application.properties
app.badmap[файл]=val1
app.badmap[file]=val2

Bug appears only when @Configuration and @ConfigurationProperties(prefix = "app") used together.

Comment From: snicoll

Rather than the screenshot, can you please share that test in the form of a minimal project? (Something we can clone or download and run ourselves). Thank you.

Comment From: Sonique

No problem. While working around I found that this bug only appears when @Configuration used with @ConfigurationProperties. Update: But without @Configuration encoding = "UTF-8" conversion not works, and text appears broken. Update2: also when you use @PropertySource and in application.properties use spring.profiles.active=dev it applies UTF-8 only to first file, maybe it's correct behavior, don't know

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

Comment From: sofiacoder3000

if I have application.yml... How it works?