Skip to content

Commit 8015f28

Browse files
committed
Merge pull request #33663 from asomov
* pr/33663: Polish 'Migrate from soon to be deprecate SnakeYAML constructor' Migrate from soon to be deprecate SnakeYAML constructor Closes gh-33663
2 parents 0a50b83 + 2faede6 commit 8015f28

File tree

1 file changed

+11
-2
lines changed
  • spring-boot-system-tests/spring-boot-image-tests/src/systemTest/java/org/springframework/boot/image/paketo

1 file changed

+11
-2
lines changed

spring-boot-system-tests/spring-boot-image-tests/src/systemTest/java/org/springframework/boot/image/paketo/LayersIndex.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
2525
import java.util.jar.JarFile;
2626
import java.util.zip.ZipEntry;
2727

28+
import org.yaml.snakeyaml.LoaderOptions;
2829
import org.yaml.snakeyaml.Yaml;
2930
import org.yaml.snakeyaml.constructor.Constructor;
3031

@@ -45,9 +46,17 @@ static LayersIndex fromArchiveFile(File archiveFile) throws IOException {
4546
String indexPath = (archiveFile.getName().endsWith(".war") ? "WEB-INF/layers.idx" : "BOOT-INF/layers.idx");
4647
try (JarFile jarFile = new JarFile(archiveFile)) {
4748
ZipEntry indexEntry = jarFile.getEntry(indexPath);
48-
Yaml yaml = new Yaml(new Constructor(LayersIndex.class));
49+
Yaml yaml = new Yaml(new Constructor(LayersIndex.class, getLoaderOptions()));
4950
return yaml.load(jarFile.getInputStream(indexEntry));
5051
}
5152
}
5253

54+
private static LoaderOptions getLoaderOptions() {
55+
LoaderOptions loaderOptions = new LoaderOptions();
56+
loaderOptions.setAllowDuplicateKeys(false);
57+
loaderOptions.setMaxAliasesForCollections(Integer.MAX_VALUE);
58+
loaderOptions.setAllowRecursiveKeys(true);
59+
return loaderOptions;
60+
}
61+
5362
}

0 commit comments

Comments
 (0)