Skip to content

Commit

Permalink
Switch from snakeyaml to snakeyaml engine (#5691)
Browse files Browse the repository at this point in the history
  • Loading branch information
trask authored Aug 8, 2023
1 parent d4a3b3b commit 88c80b1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 0 additions & 1 deletion sdk-extensions/incubator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@
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);
}
}

0 comments on commit 88c80b1

Please sign in to comment.