diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/OriginTrackedYamlLoader.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/OriginTrackedYamlLoader.java index 243675f57c..5660f46a4a 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/OriginTrackedYamlLoader.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/OriginTrackedYamlLoader.java @@ -67,6 +67,7 @@ class OriginTrackedYamlLoader extends YamlProcessor { loaderOptions.setAllowDuplicateKeys(false); loaderOptions.setMaxAliasesForCollections(Integer.MAX_VALUE); loaderOptions.setAllowRecursiveKeys(true); + loaderOptions.setCodePointLimit(Integer.MAX_VALUE); return createYaml(loaderOptions); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/OriginTrackedYamlLoaderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/OriginTrackedYamlLoaderTests.java index 68b88f9fd1..b51d41a9cd 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/OriginTrackedYamlLoaderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/OriginTrackedYamlLoaderTests.java @@ -182,6 +182,18 @@ class OriginTrackedYamlLoaderTests { 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 loaded = this.loader.load().get(0); + assertThat(loaded).isNotEmpty(); + } + private OriginTrackedValue getValue(String name) { if (this.result == null) { this.result = this.loader.load();