For a config file format I'd like to use YAML and Jackson to read it. So I have a POJO class Configuration
with a few properties and simply read a respective object directly from the file via ObjectMapper.readValue()
.
In principle that works fine, unless the configuration file is -- except for comments -- empty. Then the exception
com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input
is thrown. Since there are defaults for all configuration values, not specifying a value for any of them should be just fine, so I'd like to allow that. Is there any way to convince Jackson to accept an empty file?