cfg4j / cfg4j

Modern configuration library for distributed apps written in Java.

Home Page:http://cfg4j.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Have BindingValidator validate inherited methods

agearhart opened this issue · comments

During the binding validation methods of extended interfaces are not validated and so only fail on use later during runtime.

For example:
public interface MasterConfig extends TelemetryConfig {
Integer maxDatabaseConnections();
}

public interface TelemetryConfig {
String telemetryUrl();
}

...
ReloadStrategy reloadStrategy = new PeriodicalReloadStrategy(1, TimeUnit.MINUTES);

ConfigFilesProvider files = () -> Arrays.asList(Paths.get("/etc/company/application/config.yml"));
ConfigurationSource source = new FilesConfigurationSource(files);
ConfigurationProvider configProvider = new ConfigurationProviderBuilder().withConfigurationSource(source)
.withReloadStrategy(reloadStrategy).build();
MasterConfig config = configProvider.bind("MasterConfig", MasterConfig.class);

Upon binding only maxDatabaseConnections is validated by BindingValidator. Should telemetryUrl not be supplied in the config the application only fails when the method is referenced.