From 9afe466837e9e0751a8cd3898bca80d60548f0d1 Mon Sep 17 00:00:00 2001 From: Zheng Feng Date: Mon, 24 Jul 2023 14:11:00 +0800 Subject: [PATCH] Upgrade snakeyaml to 2.0 and springboot to 2.7.10 (#2216) --- .../elasticjob/infra/yaml/YamlEngine.java | 11 +++++++++-- .../yaml/representer/ElasticJobYamlRepresenter.java | 4 ++++ elasticjob-lite/elasticjob-lite-spring/pom.xml | 4 ++-- pom.xml | 3 ++- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/yaml/YamlEngine.java b/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/yaml/YamlEngine.java index d0d264cb1b..8bfc91791f 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/yaml/YamlEngine.java +++ b/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/yaml/YamlEngine.java @@ -20,7 +20,12 @@ import lombok.AccessLevel; import lombok.NoArgsConstructor; import org.apache.shardingsphere.elasticjob.infra.yaml.representer.ElasticJobYamlRepresenter; +import org.yaml.snakeyaml.DumperOptions; +import org.yaml.snakeyaml.LoaderOptions; import org.yaml.snakeyaml.Yaml; +import org.yaml.snakeyaml.inspector.TrustedPrefixesTagInspector; + +import java.util.Collections; /** * YAML engine. @@ -35,7 +40,7 @@ public final class YamlEngine { * @return YAML content */ public static String marshal(final Object value) { - return new Yaml(new ElasticJobYamlRepresenter()).dumpAsMap(value); + return new Yaml(new ElasticJobYamlRepresenter(new DumperOptions())).dumpAsMap(value); } /** @@ -47,6 +52,8 @@ public static String marshal(final Object value) { * @return object from YAML */ public static T unmarshal(final String yamlContent, final Class classType) { - return new Yaml().loadAs(yamlContent, classType); + LoaderOptions loaderOptions = new LoaderOptions(); + loaderOptions.setTagInspector(new TrustedPrefixesTagInspector(Collections.singletonList("org.apache.shardingsphere.elasticjob"))); + return new Yaml(loaderOptions).loadAs(yamlContent, classType); } } diff --git a/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/yaml/representer/ElasticJobYamlRepresenter.java b/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/yaml/representer/ElasticJobYamlRepresenter.java index 2cede6bcfa..233f9ff304 100644 --- a/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/yaml/representer/ElasticJobYamlRepresenter.java +++ b/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/yaml/representer/ElasticJobYamlRepresenter.java @@ -17,6 +17,7 @@ package org.apache.shardingsphere.elasticjob.infra.yaml.representer; +import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.introspector.Property; import org.yaml.snakeyaml.nodes.NodeTuple; import org.yaml.snakeyaml.nodes.Tag; @@ -26,6 +27,9 @@ * ElasticJob YAML representer. */ public final class ElasticJobYamlRepresenter extends Representer { + public ElasticJobYamlRepresenter(final DumperOptions options) { + super(options); + } @Override protected NodeTuple representJavaBeanProperty(final Object javaBean, final Property property, final Object propertyValue, final Tag customTag) { diff --git a/elasticjob-lite/elasticjob-lite-spring/pom.xml b/elasticjob-lite/elasticjob-lite-spring/pom.xml index f8ae0283d0..35804b4a2b 100644 --- a/elasticjob-lite/elasticjob-lite-spring/pom.xml +++ b/elasticjob-lite/elasticjob-lite-spring/pom.xml @@ -34,8 +34,8 @@ - 2.3.12.RELEASE - [3.1.0.RELEASE,5.2.16.RELEASE] + 2.7.10 + 5.3.26 diff --git a/pom.xml b/pom.xml index 12503b41f8..20200706cf 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,7 @@ 1.3 4.5.13 4.4.13 - 1.26 + 2.0 2.6.1 4.1.59.Final 1.1.0 @@ -801,4 +801,5 @@ dev-unsubscribe@shardingsphere.apache.org +