Skip to content

YamlPropertiesFactoryBean doesn't preserve ordering of YAML documents [SPR-12471] #17077

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

Closed
spring-projects-issues opened this issue Nov 26, 2014 · 5 comments
Assignees
Labels
status: invalid An issue that we don't feel is valid

Comments

@spring-projects-issues
Copy link
Collaborator

Graeme Rocher opened SPR-12471 and commented

Because of this code:

final Properties result = new Properties();
process(new MatchCallback() {
     @Override
     public void process(Properties properties, Map<String, Object> map) {
          result.putAll(properties);
     }
});

Ordering in YAML documents is broken since a Properties object doesn't retain ordering. This needs to be done with a LInkedHashMap instead and in fact if you look at the map passed into the process method it is a LinkedHashMap.


Affects: 4.1.2

Reference URL: apache/grails-core@d9670e1

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Actually, don't we have YamlMapFactoryBean for that purpose? It uses a LinkedHashMap already, and also exposes the end result that way.

With YamlPropertiesFactoryBean, we're bound to exposing it as java.util.Properties eventually, losing the ordering at that point...

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Graeme Rocher commented

I guess this is more of a Spring Boot issue then? Since Spring Boot uses YamlPropertiesFactoryBean by default (which doesn't seem sensible given this issue)

@spring-projects-issues
Copy link
Collaborator Author

Stéphane Nicoll commented

I guess the underlying issue is YamlPropertySourceLoader where it should use YamlMapFactoryBean. Right now it exposes a properties set.

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Indeed, it looks like Boot should be using YamlMapFactoryBean in some form. I suppose that's something to fix in time for Boot 1.2 GA still...

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Stéphane Nicoll commented

Alright, let me see what I can do in Boot. spring-projects/spring-boot#2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

2 participants