Polish 'Add origin support for empty YAML list and map'

See gh-21704
This commit is contained in:
Phillip Webb
2020-09-21 16:42:59 -07:00
parent f18d564add
commit bd2a252101
2 changed files with 6 additions and 6 deletions

View File

@@ -105,15 +105,15 @@ class OriginTrackedYamlLoader extends YamlProcessor {
@Override
protected Object constructObject(Node node) {
if (node instanceof CollectionNode && ((CollectionNode<?>) node).getValue().isEmpty()) {
return constructTrackedObject(node, super.constructObject(node));
}
if (node instanceof ScalarNode) {
if (!(node instanceof KeyScalarNode)) {
return constructTrackedObject(node, super.constructObject(node));
}
}
else if (node instanceof CollectionNode && ((CollectionNode<?>) node).getValue().isEmpty()) {
return constructTrackedObject(node, super.constructObject(node));
}
else if (node instanceof MappingNode) {
if (node instanceof MappingNode) {
replaceMappingNodeKeys((MappingNode) node);
}
return super.constructObject(node);

View File

@@ -125,8 +125,8 @@ class OriginTrackedYamlLoaderTests {
void processEmptyListAndMap() {
OriginTrackedValue emptymap = getValue("emptymap");
OriginTrackedValue emptylist = getValue("emptylist");
assertThat(emptymap.getValue()).isEqualTo(Collections.EMPTY_MAP);
assertThat(emptylist.getValue()).isEqualTo(Collections.EMPTY_LIST);
assertThat(emptymap.getValue()).isEqualTo(Collections.emptyMap());
assertThat(emptylist.getValue()).isEqualTo(Collections.emptyList());
}
@Test