Search code examples
scalatypesafetypesafe-config

What does com.typesafe.config.ConfigFactory.load(Config) do?


What does the method load(Config) in class com.typesafe.config.ConfigFactory do? How would the output Config be different from the input Config?

The documentation says that it:

Assembles a standard configuration using a custom Config object rather than loading "application.conf". The Config object will be sandwiched between the default reference config and default overrides and then resolved.

I do not understand what it is saying.

The code shows that:

public static Config load(Config config) {
    return load(checkedContextClassLoader("load"), config);
}

It seems to be loading with a checkedContextClassLoader which I don't understand. Can someone give a short understandable explanation of this?


Solution

  • How would the output Config be different from the input Config?

    It has the reference config (loaded from reference.conf) as fallback for anything not defined in the input Config, and then overrides from system properties are applied ("Future versions may get overrides in more places. It is not guaranteed that this method only uses system properties.").

    It seems to be loading with a checkedContextClassLoader which I don't understand.

    I don't think this is an important part. This is simply the default classloader used by the library.