File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed
avaje-config/src/main/java/io/avaje/config Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -23,13 +23,21 @@ final class Parsers {
2323 }
2424
2525 private void initYamlParser () {
26- YamlLoader yamlLoader ;
27- try {
28- Class .forName ("org.yaml.snakeyaml.Yaml" );
29- yamlLoader = new YamlLoaderSnake ();
30- } catch (ClassNotFoundException e ) {
31- yamlLoader = new YamlLoaderSimple ();
32- }
26+ var modules = ModuleLayer .boot ();
27+ YamlLoader yamlLoader =
28+ modules
29+ .findModule ("io.avaje.config" )
30+ .map (m -> modules .findModule ("org.yaml.snakeyaml" ).isPresent ())
31+ .map (m -> (YamlLoader ) new YamlLoaderSnake ())
32+ .orElseGet (
33+ () -> {
34+ try {
35+ return new YamlLoaderSnake ();
36+ } catch (Throwable e ) {
37+ return new YamlLoaderSimple ();
38+ }
39+ });
40+
3341 parserMap .put ("yml" , yamlLoader );
3442 parserMap .put ("yaml" , yamlLoader );
3543 }
You can’t perform that action at this time.
0 commit comments