From e3862d9bdf84fb16914157fd2098240da28e4987 Mon Sep 17 00:00:00 2001 From: dreis2211 Date: Sun, 6 May 2018 17:37:08 +0200 Subject: [PATCH] Fix deprecation warning in OriginTrackedYamlLoader Closes gh-13085 --- .../springframework/boot/env/OriginTrackedYamlLoader.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 6ebf1e7438..7976529373 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 @@ -23,6 +23,7 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; import org.yaml.snakeyaml.DumperOptions; +import org.yaml.snakeyaml.LoaderOptions; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.BaseConstructor; import org.yaml.snakeyaml.constructor.Constructor; @@ -64,7 +65,9 @@ class OriginTrackedYamlLoader extends YamlProcessor { Representer representer = new Representer(); DumperOptions dumperOptions = new DumperOptions(); LimitedResolver resolver = new LimitedResolver(); - return new Yaml(constructor, representer, dumperOptions, resolver); + LoaderOptions loaderOptions = new LoaderOptions(); + loaderOptions.setAllowDuplicateKeys(false); + return new Yaml(constructor, representer, dumperOptions, loaderOptions, resolver); } public List> load() { @@ -76,7 +79,7 @@ class OriginTrackedYamlLoader extends YamlProcessor { /** * {@link Constructor} that tracks property origins. */ - private class OriginTrackingConstructor extends StrictMapAppenderConstructor { + private class OriginTrackingConstructor extends Constructor { @Override protected Object constructObject(Node node) {