Switch from snakeyaml to snakeyaml engine (#5691)

This commit is contained in:
Trask Stalnaker 2023-08-08 13:14:47 -07:00 committed by GitHub
parent d4a3b3b680
commit 88c80b1378
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -27,7 +27,6 @@ dependencies {
// io.opentelemetry.sdk.extension.incubator.fileconfig
implementation("com.fasterxml.jackson.core:jackson-databind")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml")
implementation("org.yaml:snakeyaml:2.1")
testImplementation(project(":sdk:testing"))
testImplementation(project(":sdk-extensions:autoconfigure"))

View File

@ -8,18 +8,20 @@ package io.opentelemetry.sdk.extension.incubator.fileconfig;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.OpenTelemetryConfiguration;
import java.io.InputStream;
import org.yaml.snakeyaml.Yaml;
import org.snakeyaml.engine.v2.api.Load;
import org.snakeyaml.engine.v2.api.LoadSettings;
class ConfigurationReader {
private static final ObjectMapper MAPPER = new ObjectMapper();
private static final Yaml YAML = new Yaml();
private ConfigurationReader() {}
/** Parse the {@code configuration} YAML and return the {@link OpenTelemetryConfiguration}. */
static OpenTelemetryConfiguration parse(InputStream configuration) {
Object yamlObj = YAML.load(configuration);
LoadSettings settings = LoadSettings.builder().build();
Load yaml = new Load(settings);
Object yamlObj = yaml.loadFromInputStream(configuration);
return MAPPER.convertValue(yamlObj, OpenTelemetryConfiguration.class);
}
}