Bump up snakeyaml to 2.0 (#10495)
This commit is contained in:
parent
80e4e34967
commit
96b6690e24
|
|
@ -345,7 +345,7 @@ The text of each license is the standard Apache 2.0 license.
|
|||
https://mvnrepository.com/artifact/org.slf4j/log4j-over-slf4j/1.7.30 Apache-2.0
|
||||
https://mvnrepository.com/artifact/org.slf4j/slf4j-api/1.7.30 Apache-2.0
|
||||
https://mvnrepository.com/artifact/org.xerial.snappy/snappy-java/1.1.8.1 Apache-2.0
|
||||
https://mvnrepository.com/artifact/org.yaml/snakeyaml/1.33 Apache-2.0
|
||||
https://mvnrepository.com/artifact/org.yaml/snakeyaml/2.0 Apache-2.0
|
||||
https://npmjs.com/package/typescript/v/4.7.4 4.7.4 Apache-2.0
|
||||
|
||||
========================================================================
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
* Bump up Armeria version to 1.21.0.
|
||||
* Clean up maven `pom.xml`s.
|
||||
* Bump up Java version to 11.
|
||||
* Bump up snakeyaml to 2.0.
|
||||
|
||||
#### OAP Server
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
<joda-time.version>2.10.5</joda-time.version>
|
||||
<zookeeper.version>3.5.7</zookeeper.version>
|
||||
<guava.version>31.1-jre</guava.version>
|
||||
<snakeyaml.version>1.33</snakeyaml.version>
|
||||
<snakeyaml.version>2.0</snakeyaml.version>
|
||||
<protobuf-java.version>3.21.8</protobuf-java.version>
|
||||
<protobuf-java-util.version>3.21.8</protobuf-java-util.version>
|
||||
<commons-codec.version>1.11</commons-codec.version>
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public class MeterConfigs {
|
|||
return null;
|
||||
}
|
||||
try (Reader r = new FileReader(f)) {
|
||||
return new Yaml().loadAs(r, MeterConfig.class);
|
||||
return new Yaml().<MeterConfig>loadAs(r, MeterConfig.class);
|
||||
} catch (IOException e) {
|
||||
log.warn("Reading file {} failed", f, e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
package org.apache.skywalking.oap.server.analyzer.provider.trace.sampling;
|
||||
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtil;
|
||||
import org.yaml.snakeyaml.LoaderOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||
|
||||
|
|
@ -32,15 +33,15 @@ import java.util.Objects;
|
|||
* SamplingPolicySettings}.
|
||||
*/
|
||||
public class SamplingPolicySettingsReader {
|
||||
private Map yamlData;
|
||||
private Map<String, ?> yamlData;
|
||||
|
||||
public SamplingPolicySettingsReader(InputStream inputStream) {
|
||||
Yaml yaml = new Yaml(new SafeConstructor());
|
||||
Yaml yaml = new Yaml(new SafeConstructor(new LoaderOptions()));
|
||||
yamlData = yaml.load(inputStream);
|
||||
}
|
||||
|
||||
public SamplingPolicySettingsReader(Reader io) {
|
||||
Yaml yaml = new Yaml(new SafeConstructor());
|
||||
Yaml yaml = new Yaml(new SafeConstructor(new LoaderOptions()));
|
||||
yamlData = yaml.load(io);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,10 @@ public class YamlParserSpec extends AbstractParserSpec {
|
|||
}
|
||||
|
||||
public Yaml create() {
|
||||
return new Yaml(new SafeConstructor(), new Representer(), new DumperOptions(), loaderOptions);
|
||||
final var dumperOptions = new DumperOptions();
|
||||
return new Yaml(
|
||||
new SafeConstructor(loaderOptions),
|
||||
new Representer(dumperOptions),
|
||||
dumperOptions, loaderOptions);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class LALConfigs {
|
|||
})
|
||||
.map(f -> {
|
||||
try (final Reader r = new FileReader(f)) {
|
||||
return new Yaml().loadAs(r, LALConfigs.class);
|
||||
return new Yaml().<LALConfigs>loadAs(r, LALConfigs.class);
|
||||
} catch (IOException e) {
|
||||
log.debug("Failed to read file {}", f, e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import org.apache.skywalking.oap.server.core.alarm.provider.slack.SlackSettings;
|
|||
import org.apache.skywalking.oap.server.core.alarm.provider.wechat.WechatSettings;
|
||||
import org.apache.skywalking.oap.server.core.alarm.provider.welink.WeLinkSettings;
|
||||
import org.apache.skywalking.oap.server.library.util.CollectionUtils;
|
||||
import org.yaml.snakeyaml.LoaderOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||
|
||||
|
|
@ -48,13 +49,13 @@ public class RulesReader {
|
|||
private Map yamlData;
|
||||
|
||||
public RulesReader(InputStream inputStream) {
|
||||
Yaml yaml = new Yaml(new SafeConstructor());
|
||||
yamlData = (Map) yaml.load(inputStream);
|
||||
Yaml yaml = new Yaml(new SafeConstructor(new LoaderOptions()));
|
||||
yamlData = yaml.load(inputStream);
|
||||
}
|
||||
|
||||
public RulesReader(Reader io) {
|
||||
Yaml yaml = new Yaml(new SafeConstructor());
|
||||
yamlData = (Map) yaml.load(io);
|
||||
Yaml yaml = new Yaml(new SafeConstructor(new LoaderOptions()));
|
||||
yamlData = yaml.load(io);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import org.apache.skywalking.oap.server.configuration.api.ConfigChangeWatcher;
|
|||
import org.apache.skywalking.oap.server.core.CoreModule;
|
||||
import org.apache.skywalking.oap.server.core.CoreModuleProvider;
|
||||
import org.apache.skywalking.oap.server.library.util.ResourceUtils;
|
||||
import org.yaml.snakeyaml.LoaderOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||
|
||||
|
|
@ -95,7 +96,7 @@ public class ApdexThresholdConfig extends ConfigChangeWatcher implements Configu
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void updateConfig(final Reader contentRender) {
|
||||
dictionary = (Map<String, Integer>) new Yaml(new SafeConstructor()).load(contentRender);
|
||||
dictionary = new Yaml(new SafeConstructor(new LoaderOptions())).load(contentRender);
|
||||
if (dictionary == null) {
|
||||
dictionary = Collections.emptyMap();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtil;
|
||||
import org.yaml.snakeyaml.LoaderOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||
|
||||
|
|
@ -34,12 +35,12 @@ public class EndpointGroupingRuleReader {
|
|||
private Map yamlData;
|
||||
|
||||
public EndpointGroupingRuleReader(InputStream inputStream) {
|
||||
Yaml yaml = new Yaml(new SafeConstructor());
|
||||
Yaml yaml = new Yaml(new SafeConstructor(new LoaderOptions()));
|
||||
yamlData = (Map) yaml.load(inputStream);
|
||||
}
|
||||
|
||||
public EndpointGroupingRuleReader(Reader io) {
|
||||
Yaml yaml = new Yaml(new SafeConstructor());
|
||||
Yaml yaml = new Yaml(new SafeConstructor(new LoaderOptions()));
|
||||
yamlData = (Map) yaml.load(io);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtil;
|
||||
import org.apache.skywalking.oap.server.library.util.ResourceUtils;
|
||||
import org.yaml.snakeyaml.LoaderOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||
|
||||
|
|
@ -99,7 +100,7 @@ public class EndpointGroupingRuleReader4Openapi {
|
|||
continue;
|
||||
}
|
||||
Reader reader = new FileReader(file);
|
||||
Yaml yaml = new Yaml(new SafeConstructor());
|
||||
Yaml yaml = new Yaml(new SafeConstructor(new LoaderOptions()));
|
||||
Map openapiData = yaml.load(reader);
|
||||
if (openapiData != null) {
|
||||
serviceOpenapiDefMap.computeIfAbsent(getServiceName(openapiDefPath, file, openapiData), k -> new ArrayList<>()).add(openapiData);
|
||||
|
|
@ -119,7 +120,7 @@ public class EndpointGroupingRuleReader4Openapi {
|
|||
serviceName = itemNameInfo[0];
|
||||
}
|
||||
Reader reader = new StringReader(openapiDefs);
|
||||
Yaml yaml = new Yaml(new SafeConstructor());
|
||||
Yaml yaml = new Yaml(new SafeConstructor(new LoaderOptions()));
|
||||
Map openapiData = yaml.load(reader);
|
||||
if (openapiData != null) {
|
||||
serviceOpenapiDefMap.computeIfAbsent(getServiceName(serviceName, openapiData), k -> new ArrayList<>())
|
||||
|
|
|
|||
|
|
@ -18,18 +18,22 @@
|
|||
|
||||
package org.apache.skywalking.oap.server.library.util.yaml;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.yaml.snakeyaml.LoaderOptions;
|
||||
import org.yaml.snakeyaml.constructor.Constructor;
|
||||
|
||||
/**
|
||||
* Whitelist constructor implementation for YAML snake.
|
||||
* Copied from Apache ShardingSphere.
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public final class ClassFilterConstructor extends Constructor {
|
||||
|
||||
private final Class<?>[] acceptClasses;
|
||||
|
||||
public ClassFilterConstructor(final Class<?>[] acceptClasses) {
|
||||
super(new LoaderOptions());
|
||||
this.acceptClasses = acceptClasses;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?> getClassForName(final String name) throws ClassNotFoundException {
|
||||
for (Class<? extends Object> each : acceptClasses) {
|
||||
|
|
@ -39,4 +43,4 @@ public final class ClassFilterConstructor extends Constructor {
|
|||
}
|
||||
throw new IllegalArgumentException(String.format("Class is not accepted: %s", name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.yaml.snakeyaml.LoaderOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||
|
||||
|
|
@ -37,13 +38,13 @@ public class AgentConfigurationsReader {
|
|||
private Map yamlData;
|
||||
|
||||
public AgentConfigurationsReader(InputStream inputStream) {
|
||||
Yaml yaml = new Yaml(new SafeConstructor());
|
||||
yamlData = (Map) yaml.load(inputStream);
|
||||
Yaml yaml = new Yaml(new SafeConstructor(new LoaderOptions()));
|
||||
yamlData = yaml.load(inputStream);
|
||||
}
|
||||
|
||||
public AgentConfigurationsReader(Reader io) {
|
||||
Yaml yaml = new Yaml(new SafeConstructor());
|
||||
yamlData = (Map) yaml.load(io);
|
||||
Yaml yaml = new Yaml(new SafeConstructor(new LoaderOptions()));
|
||||
yamlData = yaml.load(io);
|
||||
}
|
||||
|
||||
public AgentConfigurationsTable readAgentConfigurationsTable() {
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public class ZabbixConfigs {
|
|||
return null;
|
||||
}
|
||||
try (Reader r = new FileReader(f)) {
|
||||
return new Yaml().loadAs(r, ZabbixConfig.class);
|
||||
return new Yaml().<ZabbixConfig>loadAs(r, ZabbixConfig.class);
|
||||
} catch (IOException e) {
|
||||
log.warn("Reading file {} failed", f, e);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue