Add DumperOptions for yaml parsing
package org.apache.shenyu.agent.core.yaml;
+import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
import java.io.File;
@@ -29,6 +30,12 @@ import java.io.InputStreamReader;
*/
public final class ShenyuYamlEngine {
+ private static final DumperOptions DUMPER_OPTIONS = new DumperOptions();
+
+ static {
+ DUMPER_OPTIONS.setLineBreak(DumperOptions.LineBreak.getPlatformLineBreak());
+ }
+
/**
* Unmarshal t.
*
@@ -43,7 +50,7 @@ public final class ShenyuYamlEngine {
FileInputStream fileInputStream = new FileInputStream(yamlFile);
InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream)
) {
- return new Yaml().loadAs(inputStreamReader, classType);
+ return new Yaml(DUMPER_OPTIONS).loadAs(inputStreamReader, classType);
}
}
}
