Skip to content

Commit

Permalink
Upgrade snakeyaml to 2.0 and springboot to 2.7.10 (#2216)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhfeng authored Jul 24, 2023
1 parent a7042cf commit 9afe466
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
}

/**
Expand All @@ -47,6 +52,8 @@ public static String marshal(final Object value) {
* @return object from YAML
*/
public static <T> T unmarshal(final String yamlContent, final Class<T> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions elasticjob-lite/elasticjob-lite-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
</modules>

<properties>
<springboot.version>2.3.12.RELEASE</springboot.version>
<springframework.version>[3.1.0.RELEASE,5.2.16.RELEASE]</springframework.version>
<springboot.version>2.7.10</springboot.version>
<springframework.version>5.3.26</springframework.version>
</properties>

<dependencyManagement>
Expand Down
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<commons-exec.version>1.3</commons-exec.version>
<httpclient.version>4.5.13</httpclient.version>
<httpcore.version>4.4.13</httpcore.version>
<snakeyaml.version>1.26</snakeyaml.version>
<snakeyaml.version>2.0</snakeyaml.version>
<gson.version>2.6.1</gson.version>
<netty.version>4.1.59.Final</netty.version>
<mesos.version>1.1.0</mesos.version>
Expand Down Expand Up @@ -801,4 +801,5 @@
<unsubscribe>[email protected]</unsubscribe>
</mailingList>
</mailingLists>

</project>

0 comments on commit 9afe466

Please sign in to comment.