Skip to content

Commit a095a3a

Browse files
asomovphilwebb
authored andcommitted
Migrate from soon to be deprecate SnakeYAML constructor
Update `LayersIndex` to use constructor that accepts `LoaderOptions`. See gh-33663
1 parent 0a50b83 commit a095a3a

File tree

1 file changed

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

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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,7 +46,11 @@ 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+
LoaderOptions loaderOptions = new LoaderOptions();
50+
loaderOptions.setAllowDuplicateKeys(false);
51+
loaderOptions.setMaxAliasesForCollections(Integer.MAX_VALUE);
52+
loaderOptions.setAllowRecursiveKeys(true);
53+
Yaml yaml = new Yaml(new Constructor(LayersIndex.class, loaderOptions));
4954
return yaml.load(jarFile.getInputStream(indexEntry));
5055
}
5156
}

0 commit comments

Comments
 (0)