From 1f9ce508f7f996bcba8d7707a06ab0210ec5089a Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 19 Jun 2023 12:16:49 +0100 Subject: [PATCH] Upgrade to SnakeYAML 2.0 Closes gh-35982 --- .../spring-boot-dependencies/build.gradle | 2 +- .../spring-boot-docs/build.gradle | 11 +++++++ .../env/OriginTrackedYamlLoaderTests.java | 4 +-- ...lPropertySourceLoaderSnakeYaml20Tests.java | 29 ------------------- 4 files changed, 14 insertions(+), 32 deletions(-) delete mode 100644 spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/YamlPropertySourceLoaderSnakeYaml20Tests.java diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 133b97fcad5..994d576ea33 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1375,7 +1375,7 @@ bom { ] } } - library("SnakeYAML", "1.33") { + library("SnakeYAML", "2.0") { group("org.yaml") { modules = [ "snakeyaml" diff --git a/spring-boot-project/spring-boot-docs/build.gradle b/spring-boot-project/spring-boot-docs/build.gradle index 583522f5905..3d0d6ddcd8a 100644 --- a/spring-boot-project/spring-boot-docs/build.gradle +++ b/spring-boot-project/spring-boot-docs/build.gradle @@ -17,6 +17,17 @@ configurations { remoteSpringApplicationExample springApplicationExample testSlices + asciidoctorExtensions { + resolutionStrategy { + eachDependency { dependency -> + // Downgrade SnakeYAML as Asciidoctor fails due to an incompatibility + // in the Pysch gem + if (dependency.requested.group.equals("org.yaml")) { + dependency.useVersion("1.33") + } + } + } + } } jar { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/OriginTrackedYamlLoaderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/OriginTrackedYamlLoaderTests.java index b51d41a9cdf..ce5fa86434b 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/OriginTrackedYamlLoaderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/OriginTrackedYamlLoaderTests.java @@ -23,7 +23,7 @@ import java.util.Map; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.yaml.snakeyaml.constructor.ConstructorException; +import org.yaml.snakeyaml.composer.ComposerException; import org.springframework.boot.origin.OriginTrackedValue; import org.springframework.boot.origin.TextResourceOrigin; @@ -134,7 +134,7 @@ class OriginTrackedYamlLoaderTests { String yaml = "value: !!java.net.URL [!!java.lang.String [!!java.lang.StringBuilder [\"http://localhost:9000/\"]]]"; Resource resource = new ByteArrayResource(yaml.getBytes(StandardCharsets.UTF_8)); this.loader = new OriginTrackedYamlLoader(resource); - assertThatExceptionOfType(ConstructorException.class).isThrownBy(this.loader::load); + assertThatExceptionOfType(ComposerException.class).isThrownBy(this.loader::load); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/YamlPropertySourceLoaderSnakeYaml20Tests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/YamlPropertySourceLoaderSnakeYaml20Tests.java deleted file mode 100644 index 68444017652..00000000000 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/YamlPropertySourceLoaderSnakeYaml20Tests.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2012-2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.env; - -import org.springframework.boot.testsupport.classpath.ClassPathOverrides; - -/** - * Tests for {@link YamlPropertySourceLoader} with SnakeYAML 2.0. - * - * @author Andy Wilkinson - */ -@ClassPathOverrides("org.yaml:snakeyaml:2.0") -class YamlPropertySourceLoaderSnakeYaml20Tests extends YamlPropertySourceLoaderTests { - -}