kumuluz / kumuluzee

Lightweight open-source framework for developing microservices using standard Java EE technologies and migrating Java EE to cloud-native architecture.
https://ee.kumuluz.com
MIT License
291 stars 71 forks source link

FileConfigurationSource tries to parse properties file as YAML #209

Closed bannmann closed 2 years ago

bannmann commented 2 years ago

57 claims to have added support for configuring the path to the configuration file. However, this does not work - at least not for this property file:

foo=bb4c62ba-24f1-49cb-8f9d-e635dd2f99f5
bar=02c31bb1-305d-4e40-ac69-6f3adfabf943

# something.SOME-UUID, see https://example.org/foo/#config
my.example-key.subkey=something.8a1898ce-6512-46c7-b8f8-5fae5b77453a

Running a KumuluzEE 3.12.1 app with -Dcom.kumuluz.ee.configuration.file=/path/to/my/config.properties results in the following exception:

Exception in thread "main" expected '<document start>', but found '<scalar>'
 in 'reader', line 5, column 1:
    my.example-key.subkey=something. ...
    ^
        at org.yaml.snakeyaml.parser.ParserImpl$ParseDocumentStart.produce(ParserImpl.java:225)
        at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158)
        at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:148)
        at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:122)
        at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:150)
        at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:490)
        at org.yaml.snakeyaml.Yaml.load(Yaml.java:429)
        at com.kumuluz.ee.configuration.sources.FileConfigurationSource.init(FileConfigurationSource.java:113)

I'm not sure what exactly makes that property file invalid YAML, but that's beside the point.

Kumuluz EE should either

  1. not even attempt to parse a file called .properties as YAML, or
  2. catch the YAML parse error silently and fall back to parsing as properties file.
urbim commented 2 years ago

Hi! Thanks for reporting this.

catch the YAML parse error silently and fall back to parsing as properties file.

This is indeed the way this was meant to be handled.