Skip to content

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

Open
@leonardo-dgs

Description

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions