Not fully consistent ordering in spring-configuration-metadata.json
See original GitHub issueCurrent comparator implementation produces not consistent order for special case, when a codebase contains multiple classes that shares same “namespace” and (optionally) same properties.
Consider this example:
package com.example;
@ConfigurationProperties("app.section")
public class Foo {
private int val;
}
@ConfigurationProperties("app.section")
public class Bar {
private boolean flag;
private int val;
}
As both classes share same section (and it works in runtime just fine), this leads to multiple outcomes in groups
sections, as well as in properties
section:
"groups": [
{
"name": "app.section", // order can be swapped!
"type": "com.example.Foo",
"sourceType": "com.example.Foo"
},
{
"name": "app.section",
"type": "com.example.Bar",
"sourceType": "com.example.Bar""
}
],
Same is applied for val
in this exampe, as name is same, but type/sourceType is different.
I understand that this is extreme example, but it is valid in terms of spring support, so I think that adding sort stage for type can solve this problem:
private final Comparator<ItemMetadata> propertyComparator = Comparator.<ItemMetadata, Boolean>comparing(ItemMetadata::isDeprecated)
.thenComparing(ItemMetadata::getName)
.thenComparing(ItemMetadata::getType);
private final Comparator<ItemMetadata> groupComparator = Comparator.<ItemMetadata, String>comparing(ItemMetadata::getName).thenComparing(ItemMetadata::getType);
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:10 (10 by maintainers)
Top Results From Across the Web
Configuration Metadata - Spring
Configuration metadata files are located inside jars under META-INF/spring-configuration-metadata.json . They use a JSON format with items ...
Read more >Accessing Spring Configuration Properties Metadata through ...
I would like to be able to add items to the metadata JSON and then retrieve them with the Spring API, instead of...
Read more >A Guide to Spring Boot Configuration Metadata - Baeldung
In this tutorial, we'll explore the Spring Boot Configuration Processor and the associated JSON metadata files that document each property's ...
Read more >Zalando RESTful API and Event Guidelines
The requirement level keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" used in this ...
Read more >A Guide to Spring Boot Configuration Metadata - Morioh
In this tutorial, we'll explore the Spring Boot Configuration Processor and the associated JSON metadata files that document each property's meaning, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Deal. I’m going to work on PR this weekend.
OK, looks like I need to get familiar with the process better, sorry.