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

Add origin support for empty YAML list and map #20506

Closed
copa2 opened this issue Mar 12, 2020 · 3 comments
Closed

Add origin support for empty YAML list and map #20506

copa2 opened this issue Mar 12, 2020 · 3 comments
Labels
status: superseded An issue that has been superseded by another type: enhancement A general enhancement

Comments

@copa2
Copy link

copa2 commented Mar 12, 2020

While searching the root cause for spring-cloud/spring-cloud-config#1572 I reviewed OriginTrackedYamlLoader. In cases of an empty list or empty map there is no origin created.

Reproduction
Add to https://raw.githubusercontent.com/spring-projects/spring-boot/master/spring-boot-project/spring-boot/src/test/resources/org/springframework/boot/env/test-yaml.yml

emptylist: []
emptymap: {}

and extend testcases for emptylist and emptymap.

Fix
Add additional code for CollectionNodes which are empty In OriginTrackedYamlLoader.constructObject between ScalarNode and MappingNode check.

} else if (node instanceof CollectionNode && ((CollectionNode<?>) node).getValue().isEmpty()) {
   return constructTrackedObject(node, super.constructObject(node));
}

protected Object constructObject(Node node) {
if (node instanceof ScalarNode) {
if (!(node instanceof KeyScalarNode)) {
return constructTrackedObject(node, super.constructObject(node));
}
}
else if (node instanceof MappingNode) {
replaceMappingNodeKeys((MappingNode) node);
}
return super.constructObject(node);
}

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 12, 2020
@mbhave mbhave added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 12, 2020
@mbhave mbhave added this to the 2.x milestone Mar 12, 2020
@mbhave mbhave changed the title OriginTrackedYamlLoader support emptylist ([]) and emptymap ({}) Add origin support for empty YAML list and map Mar 12, 2020
unix1982 added a commit to unix1982/spring-boot that referenced this issue Jun 4, 2020
@mbhave
Copy link
Contributor

mbhave commented Jun 9, 2020

Closing in favor of PR #21704.

@mbhave mbhave added the status: superseded An issue that has been superseded by another label Jun 11, 2020
@mbhave mbhave removed this from the 2.x milestone Jun 11, 2020
@izeye
Copy link
Contributor

izeye commented Jun 23, 2020

It seems that @mbhave intended to close this.

@wilkinsona
Copy link
Member

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded An issue that has been superseded by another type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants