Allow loading of YAML files bigger than 3 MB

Closes gh-34743
pull/35611/head
Moritz Halbritter 2 years ago
parent 5c610de678
commit 077f61bd5d

@ -67,6 +67,7 @@ class OriginTrackedYamlLoader extends YamlProcessor {
loaderOptions.setAllowDuplicateKeys(false); loaderOptions.setAllowDuplicateKeys(false);
loaderOptions.setMaxAliasesForCollections(Integer.MAX_VALUE); loaderOptions.setMaxAliasesForCollections(Integer.MAX_VALUE);
loaderOptions.setAllowRecursiveKeys(true); loaderOptions.setAllowRecursiveKeys(true);
loaderOptions.setCodePointLimit(Integer.MAX_VALUE);
return createYaml(loaderOptions); return createYaml(loaderOptions);
} }

@ -182,6 +182,18 @@ class OriginTrackedYamlLoaderTests {
assertThat(loaded.get("some.anotherpath.config.key")).hasToString("value"); assertThat(loaded.get("some.anotherpath.config.key")).hasToString("value");
} }
@Test
void canLoadFilesBiggerThan3Mb() {
StringBuilder yaml = new StringBuilder();
while (yaml.length() < 4_194_304) {
yaml.append("- some list entry\n");
}
Resource resource = new ByteArrayResource(yaml.toString().getBytes(StandardCharsets.UTF_8));
this.loader = new OriginTrackedYamlLoader(resource);
Map<String, Object> loaded = this.loader.load().get(0);
assertThat(loaded).isNotEmpty();
}
private OriginTrackedValue getValue(String name) { private OriginTrackedValue getValue(String name) {
if (this.result == null) { if (this.result == null) {
this.result = this.loader.load(); this.result = this.loader.load();

Loading…
Cancel
Save