Skip to content

Commit 2faede6

Browse files
committed
Polish 'Migrate from soon to be deprecate SnakeYAML constructor'
See gh-33663
1 parent a095a3a commit 2faede6

File tree

1 file changed

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

1 file changed

+10
-6
lines changed

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

Lines changed: 10 additions & 6 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.
@@ -46,13 +46,17 @@ static LayersIndex fromArchiveFile(File archiveFile) throws IOException {
4646
String indexPath = (archiveFile.getName().endsWith(".war") ? "WEB-INF/layers.idx" : "BOOT-INF/layers.idx");
4747
try (JarFile jarFile = new JarFile(archiveFile)) {
4848
ZipEntry indexEntry = jarFile.getEntry(indexPath);
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));
49+
Yaml yaml = new Yaml(new Constructor(LayersIndex.class, getLoaderOptions()));
5450
return yaml.load(jarFile.getInputStream(indexEntry));
5551
}
5652
}
5753

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+
5862
}

0 commit comments

Comments
 (0)