use of io.dropwizard.configuration.ConfigurationValidationException in project Singularity by HubSpot.
the class SingularityRunnerConfigurationProvider method get.
@Override
public T get() {
final Configuration configuration = clazz.getAnnotation(Configuration.class);
try {
final File baseFile = new File(configuration.filename());
final T baseConfig = baseFile.exists() ? objectMapper.readValue(baseFile, clazz) : clazz.newInstance();
final JsonNode overrideNode = filename.isPresent() ? loadYamlField(filename.get(), configuration.consolidatedField()) : objectMapper.createObjectNode();
final T config = objectMapper.readerForUpdating(baseConfig).readValue(overrideNode);
final Set<ConstraintViolation<T>> violations = validator.validate(config);
if (!violations.isEmpty()) {
throw new ConfigurationValidationException(filename.or(configuration.filename()), violations);
}
return config;
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
Aggregations