While searching the root cause for https://github.com/spring-cloud/spring-cloud-config/issues/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));
}
https://github.com/spring-projects/spring-boot/blob/a66c4d3096877b33119366ea9ea165c892b462c8/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/OriginTrackedYamlLoader.java#L85-L95
Comment From: mbhave
Closing in favor of PR #21704.
Comment From: izeye
It seems that @mbhave intended to close this.
Comment From: wilkinsona
Thanks.