Skip to content

Commit

Permalink
[#11906] Use jackson instead of snakeyaml
Browse files Browse the repository at this point in the history
  • Loading branch information
intr3p1d committed Jan 6, 2025
1 parent 91ef90c commit 2d8db32
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class ProfilerLibs {
public static final List<String> PINPOINT_PROFILER_CLASS;

static {
String[] lib = new String[] {
String[] lib = new String[]{
"com.navercorp.pinpoint.common.buffer",
"com.navercorp.pinpoint.common.profiler",
"com.navercorp.pinpoint.profiler",
Expand Down Expand Up @@ -66,8 +66,9 @@ public class ProfilerLibs {
// google guice
"com.google.inject",
"org.aopalliance",
// snakeyaml
"org.yaml.snakeyaml",

// jackson
"com.fasterxml.jackson",

"org.apache.commons.lang",
"org.apache.commons.logging",
Expand Down
19 changes: 14 additions & 5 deletions agent-module/plugins-loader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>${snakeyaml.version}</version>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${fastxml.jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>${fastxml.jackson.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
Expand All @@ -39,8 +44,12 @@
</dependency>

<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
</dependency>

<!-- Logging dependencies -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@

package com.navercorp.pinpoint.loader.plugins.trace.yaml;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.navercorp.pinpoint.common.trace.AnnotationKey;
import com.navercorp.pinpoint.common.trace.ParsedTraceMetadataProvider;
import com.navercorp.pinpoint.common.trace.ServiceTypeInfo;
import com.navercorp.pinpoint.common.util.CollectionUtils;
import com.navercorp.pinpoint.loader.plugins.trace.TraceMetadataProviderParser;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.error.YAMLException;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -60,23 +62,17 @@ public ParsedTraceMetadataProvider parse(URL url) {
}

private ParsedTraceMetadata parse0(URL metaUrl) throws IOException {
InputStream inputStream = null;
try {
inputStream = metaUrl.openStream();
Yaml yaml = new Yaml();
ParsedTraceMetadata parsedTraceMetadata = yaml.loadAs(inputStream, ParsedTraceMetadata.class);
try (InputStream inputStream = metaUrl.openStream()) {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
ParsedTraceMetadata parsedTraceMetadata = mapper.readValue(inputStream, ParsedTraceMetadata.class);
if (parsedTraceMetadata == null) {
logger.warn("Empty type provider definition. Skipping : {}", metaUrl.toExternalForm());
}
return parsedTraceMetadata;
} catch (JsonParseException | JsonMappingException e) {
throw new IllegalStateException("Error parsing yml : " + metaUrl, e);
} catch (IOException e) {
throw new IllegalStateException("Error opening stream : " + metaUrl, e);
} catch (YAMLException e) {
throw new IllegalStateException("Error parsing yml : " + metaUrl, e);
} finally {
if (inputStream != null) {
inputStream.close();
}
}
}

Expand Down

0 comments on commit 2d8db32

Please # to comment.