Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yaml#addDefaultsFromInputStream messes the order of keys even if the DataType is sorted #81

Open
leonardo-dgs opened this issue Apr 19, 2023 · 0 comments

Comments

@leonardo-dgs
Copy link
Contributor

Describe the bug
When you use Yaml#addDefaultsFromInputStream, the saved config is no longer ordered, even if you set DataType.SORTED.

To Reproduce
The following code produces an unordered Yaml file.

    private Yaml loadLangConfig(String langCode) {
        File file = new File(langFolder.toPath().toString(), langCode + ".yml");
        Yaml langConfig = SimplixBuilder.fromFile(file)
                .setReloadSettings(ReloadSettings.INTELLIGENT)
                .setDataType(DataType.SORTED)
                .createYaml();

        InputStream resource = getDefaultLangFileStream(langCode);
        if (resource == null) {
            resource = getDefaultLangFileStream(settings.getDefaultLanguage());
            if (resource == null)
                resource = getDefaultLangFileStream("en_us.yml");
        }
        langConfig.addDefaultsFromInputStream(resource);

        return langConfig;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant