Skip to content

Commit

Permalink
Update snakeyaml version to v2 (#2523)
Browse files Browse the repository at this point in the history
* Update snakeyaml version

* User LoaderOptions in snakeyaml2

* Run target formatJava
  • Loading branch information
nikhil-sk committed Aug 8, 2023
1 parent 86aff0c commit 96450b9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.pytorch.serve.archive.DownloadArchiveException;
import org.pytorch.serve.archive.model.InvalidModelException;
import org.pytorch.serve.archive.s3.HttpUtils;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor;
import org.yaml.snakeyaml.error.YAMLException;
Expand All @@ -47,7 +48,7 @@ public static <T> T readFile(File file, Class<T> type)

public static <T> T readYamlFile(File file, Class<T> type)
throws InvalidModelException, IOException {
Yaml yaml = new Yaml(new Constructor(type));
Yaml yaml = new Yaml(new Constructor(type, new LoaderOptions()));
try (Reader r =
new InputStreamReader(
Files.newInputStream(file.toPath()), StandardCharsets.UTF_8)) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ slf4j_api_version=1.7.32
slf4j_log4j_version=2.17.1
testng_version=7.1.0
torchserve_sdk_version=0.0.5
snakeyaml_version=1.31
snakeyaml_version=2.1
grpc_version=1.50.0
protoc_version=3.18.0
lmax_disruptor_version=3.4.4
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.composer.ComposerException;
import org.yaml.snakeyaml.constructor.Constructor;
Expand Down Expand Up @@ -64,7 +65,7 @@ public void validate() {

public static MetricConfiguration loadConfiguration(String configFilePath)
throws FileNotFoundException, ComposerException, RuntimeException {
Constructor constructor = new Constructor(MetricConfiguration.class);
Constructor constructor = new Constructor(MetricConfiguration.class, new LoaderOptions());
Yaml yaml = new Yaml(constructor);
FileInputStream inputStream = new FileInputStream(new File(configFilePath));
MetricConfiguration config = yaml.load(inputStream);
Expand Down

0 comments on commit 96450b9

Please sign in to comment.