Switch from snakeyaml to snakeyaml-engine (#5138)

* switch from snakeyaml to snakeyaml-engine

* spotless
This commit is contained in:
jason plumb 2023-01-26 15:29:08 -08:00 committed by GitHub
parent 59043802e6
commit 8b01e78f42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 5 deletions

View File

@ -22,7 +22,7 @@ val DEPENDENCY_BOMS = listOf(
"io.zipkin.reporter2:zipkin-reporter-bom:2.16.3",
"org.junit:junit-bom:5.9.2",
"org.testcontainers:testcontainers-bom:1.17.6",
"org.yaml:snakeyaml:1.33"
"org.snakeyaml:snakeyaml-engine:2.6"
)
val autoValueVersion = "1.10.1"

View File

@ -20,7 +20,7 @@ dependencies {
// io.opentelemetry.sdk.extension.incubator.metric.viewconfig
implementation(project(":sdk-extensions:autoconfigure-spi"))
implementation("org.yaml:snakeyaml")
implementation("org.snakeyaml:snakeyaml-engine")
// io.opentelemetry.sdk.extension.trace.zpages
implementation(project(":semconv"))

View File

@ -27,7 +27,8 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import javax.annotation.Nullable;
import org.yaml.snakeyaml.Yaml;
import org.snakeyaml.engine.v2.api.Load;
import org.snakeyaml.engine.v2.api.LoadSettings;
/**
* Enables file based YAML configuration of Metric SDK {@link View}s.
@ -94,10 +95,14 @@ public final class ViewConfig {
// Visible for testing
@SuppressWarnings("unchecked")
static List<ViewConfigSpecification> loadViewConfig(InputStream inputStream) {
Yaml yaml = new Yaml();
LoadSettings settings = LoadSettings.builder().build();
Load yaml = new Load(settings);
try {
List<ViewConfigSpecification> result = new ArrayList<>();
List<Map<String, Object>> viewConfigs = yaml.load(inputStream);
List<Map<String, Object>> viewConfigs =
(List<Map<String, Object>>) yaml.loadFromInputStream(inputStream);
for (Map<String, Object> viewConfigSpecMap : viewConfigs) {
Map<String, Object> selectorSpecMap =
requireNonNull(