Skip to content

Commit

Permalink
Upgrade to snakeyaml 2.0 according to https://bitbucket.org/snakeyaml…
Browse files Browse the repository at this point in the history
  • Loading branch information
Pil0tXia committed May 18, 2024
1 parent 6c3a930 commit c57540d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,6 @@ subprojects {
dependency "com.github.seancfoley:ipaddress:5.3.3"
dependency "com.google.code.gson:gson:2.8.2"

dependency "org.yaml:snakeyaml:1.30"
dependency "org.javassist:javassist:3.30.2-GA"

dependency "com.alibaba.nacos:nacos-client:2.2.3"
Expand Down
2 changes: 1 addition & 1 deletion eventmesh-common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ dependencies {
api "com.fasterxml.jackson.core:jackson-databind"
api "com.fasterxml.jackson.core:jackson-core"
api "com.fasterxml.jackson.core:jackson-annotations"
api "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml"
api "com.fasterxml.jackson.datatype:jackson-datatype-jsr310"

implementation "org.apache.httpcomponents:httpclient"
Expand All @@ -53,7 +54,6 @@ dependencies {
implementation "javax.annotation:javax.annotation-api:1.3.2"

testImplementation "org.junit-pioneer:junit-pioneer"
implementation "org.yaml:snakeyaml"

compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ConfigInfo {
public class ConfigInfo<T> {

public static final String HUMP_SPOT = "spot";
public static final String HUMP_ROD = "rod";
Expand All @@ -40,7 +40,7 @@ public class ConfigInfo {
private boolean monitor;
private boolean removePrefix;

private Class<?> clazz;
private Class<? super T> clazz;
private Object object;
private String filePath;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@

import org.apache.commons.lang3.StringUtils;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Objects;
Expand Down Expand Up @@ -100,7 +101,10 @@ class YamlFileLoad implements FileLoad {
@Override
public <T> T getConfig(ConfigInfo configInfo) throws IOException {
Yaml yaml = new Yaml();
return (T) yaml.loadAs(new BufferedInputStream(new FileInputStream(configInfo.getFilePath())), configInfo.getClazz());
try (InputStream input = Files.newInputStream(Paths.get(configInfo.getFilePath()));
Reader reader = new InputStreamReader(input, StandardCharsets.UTF_8)) {
return (T) yaml.loadAs(reader, configInfo.getClazz());
}
}
}
}

0 comments on commit c57540d

Please sign in to comment.