mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-15 01:07:30 +08:00
Migrate from soon to be deprecate SnakeYAML constructor
Update `LayersIndex` to use constructor that accepts `LoaderOptions`. See gh-33663
This commit is contained in:
parent
0a50b83c75
commit
a095a3a888
@ -25,6 +25,7 @@ import java.util.Map;
|
|||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
|
|
||||||
|
import org.yaml.snakeyaml.LoaderOptions;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
import org.yaml.snakeyaml.constructor.Constructor;
|
import org.yaml.snakeyaml.constructor.Constructor;
|
||||||
|
|
||||||
@ -45,7 +46,11 @@ class LayersIndex extends ArrayList<Map<String, List<String>>> {
|
|||||||
String indexPath = (archiveFile.getName().endsWith(".war") ? "WEB-INF/layers.idx" : "BOOT-INF/layers.idx");
|
String indexPath = (archiveFile.getName().endsWith(".war") ? "WEB-INF/layers.idx" : "BOOT-INF/layers.idx");
|
||||||
try (JarFile jarFile = new JarFile(archiveFile)) {
|
try (JarFile jarFile = new JarFile(archiveFile)) {
|
||||||
ZipEntry indexEntry = jarFile.getEntry(indexPath);
|
ZipEntry indexEntry = jarFile.getEntry(indexPath);
|
||||||
Yaml yaml = new Yaml(new Constructor(LayersIndex.class));
|
LoaderOptions loaderOptions = new LoaderOptions();
|
||||||
|
loaderOptions.setAllowDuplicateKeys(false);
|
||||||
|
loaderOptions.setMaxAliasesForCollections(Integer.MAX_VALUE);
|
||||||
|
loaderOptions.setAllowRecursiveKeys(true);
|
||||||
|
Yaml yaml = new Yaml(new Constructor(LayersIndex.class, loaderOptions));
|
||||||
return yaml.load(jarFile.getInputStream(indexEntry));
|
return yaml.load(jarFile.getInputStream(indexEntry));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user