Skip to content

Commit cc9b3b7

Browse files
authored
Allow loader options when loading YAML (#563)
## Usage and product changes Allow setting `snakeyaml.LoaderOptions` when loading YAML ## Motivation We have run into issues caused by YAML alias count limits that we would like to resolve by modifying that limit - which is done for `snakeyaml` through the `LoaderOptions` object. ## Implementation We add alternative implementations of `load` that take a `snakeyaml.LoaderOptions` and use it when constructing the `snakeyaml.Yaml` object.
1 parent 5219103 commit cc9b3b7

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

common/java/BUILD

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ assemble_maven(
3737
version_overrides = version(artifacts_org = artifacts, artifacts_repo={}),
3838
project_name = "TypeDB Common",
3939
project_description = "TypeDB Common classes and tools",
40-
project_url = "https://github.com/typedb/typeql",
41-
scm_url = "https://github.com/typedb/typeql",
40+
project_url = "https://github.com/typedb/typedb-dependencies",
41+
scm_url = "https://github.com/typedb/typedb-dependencies",
4242
)
4343

4444
deploy_maven(

common/java/yaml/YAML.java

+9
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,20 @@ public static YAML load(java.lang.String yaml) {
2323
return wrap(new org.yaml.snakeyaml.Yaml().load(yaml));
2424
}
2525

26+
public static YAML load(java.lang.String yaml, org.yaml.snakeyaml.LoaderOptions loaderOptions) {
27+
return wrap(new org.yaml.snakeyaml.Yaml(loaderOptions).load(yaml));
28+
}
29+
2630
public static YAML load(Path filePath) throws FileNotFoundException {
2731
FileInputStream inputStream = new FileInputStream(filePath.toFile());
2832
return wrap(new org.yaml.snakeyaml.Yaml().load(inputStream));
2933
}
3034

35+
public static YAML load(Path filePath, org.yaml.snakeyaml.LoaderOptions loaderOptions) throws FileNotFoundException {
36+
FileInputStream inputStream = new FileInputStream(filePath.toFile());
37+
return wrap(new org.yaml.snakeyaml.Yaml(loaderOptions).load(inputStream));
38+
}
39+
3140
private static YAML wrap(Object yaml) {
3241
if (yaml == null) return null;
3342
else if (yaml instanceof java.util.Map) {

0 commit comments

Comments
 (0)