Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit 96450b9

Browse files
authored
Update snakeyaml version to v2 (#2523)
* Update snakeyaml version * User LoaderOptions in snakeyaml2 * Run target formatJava
1 parent 86aff0c commit 96450b9

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

frontend/archive/src/main/java/org/pytorch/serve/archive/utils/ArchiveUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.pytorch.serve.archive.DownloadArchiveException;
2222
import org.pytorch.serve.archive.model.InvalidModelException;
2323
import org.pytorch.serve.archive.s3.HttpUtils;
24+
import org.yaml.snakeyaml.LoaderOptions;
2425
import org.yaml.snakeyaml.Yaml;
2526
import org.yaml.snakeyaml.constructor.Constructor;
2627
import org.yaml.snakeyaml.error.YAMLException;
@@ -47,7 +48,7 @@ public static <T> T readFile(File file, Class<T> type)
4748

4849
public static <T> T readYamlFile(File file, Class<T> type)
4950
throws InvalidModelException, IOException {
50-
Yaml yaml = new Yaml(new Constructor(type));
51+
Yaml yaml = new Yaml(new Constructor(type, new LoaderOptions()));
5152
try (Reader r =
5253
new InputStreamReader(
5354
Files.newInputStream(file.toPath()), StandardCharsets.UTF_8)) {

frontend/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ slf4j_api_version=1.7.32
88
slf4j_log4j_version=2.17.1
99
testng_version=7.1.0
1010
torchserve_sdk_version=0.0.5
11-
snakeyaml_version=1.31
11+
snakeyaml_version=2.1
1212
grpc_version=1.50.0
1313
protoc_version=3.18.0
1414
lmax_disruptor_version=3.4.4

frontend/server/src/main/java/org/pytorch/serve/metrics/configuration/MetricConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.util.List;
77
import org.slf4j.Logger;
88
import org.slf4j.LoggerFactory;
9+
import org.yaml.snakeyaml.LoaderOptions;
910
import org.yaml.snakeyaml.Yaml;
1011
import org.yaml.snakeyaml.composer.ComposerException;
1112
import org.yaml.snakeyaml.constructor.Constructor;
@@ -64,7 +65,7 @@ public void validate() {
6465

6566
public static MetricConfiguration loadConfiguration(String configFilePath)
6667
throws FileNotFoundException, ComposerException, RuntimeException {
67-
Constructor constructor = new Constructor(MetricConfiguration.class);
68+
Constructor constructor = new Constructor(MetricConfiguration.class, new LoaderOptions());
6869
Yaml yaml = new Yaml(constructor);
6970
FileInputStream inputStream = new FileInputStream(new File(configFilePath));
7071
MetricConfiguration config = yaml.load(inputStream);

0 commit comments

Comments
 (0)