How can I check if my Spark application have no application.conf?
I read this conf with:
Config configuracion = ConfigFactory.load();
But when I check:
if (null != configuracion && !configuracion.isEmpty() && !configuracion.entrySet().isEmpty()){
config_exists = true;
}
It always return config_exists=true.
Thanks!!
The problem is that ConfigFactory.load()
loads the system properties. Therefore the resulting Config
object is not empty.
I have a hack for you, there might be a simpler way I don't know about.
Config conf = ConfigFactory.load();
// create a config containing only the system properties
Config emptyConfig = ConfigFactory.systemProperties();
// check that the loaded config is not equal to this "empty config"
Boolean isDefinedConfig = ! conf.equals(emptyConfig);