Skip to content

Commit

Permalink
Merge pull request #104 from zalando-stups/log-info-warn
Browse files Browse the repository at this point in the history
clarified log messages on configuration mismatches
  • Loading branch information
lukasniemeier-zalando committed Feb 8, 2024
2 parents 4bafd8f + 2cd5f45 commit 6975733
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected Object handleInvocation(Object proxy, Method method, Object[] args) {
final String key = createKey(getClass(proxy), method);
final Object result = getConfig(key);
if (result == null) {
LOG.warn("Configuration not found for key: {}", key);
LOG.warn("No configuration found for key [{}] in configuration source, falling back to null.", key);
return null;
}
if (!method.getReturnType().isInstance(result)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ public List<Configuration<?>> parseConfigurations(final String text) {
.collect(toList());
}

public Optional<Configuration<?>> parseConfiguration(final String text) {
Optional<Configuration<JsonNode>> rawConfig = parseConfigText(text, new TypeReference<>() {
});
return rawConfig.flatMap(this::convertToTypedConfig);
}

private <T> Optional<T> parseConfigText(final String text, TypeReference<T> type) {
if (text == null || text.isEmpty()) {
LOG.warn("Input to parse is empty: {}", text);
Expand All @@ -75,7 +69,10 @@ private Optional<Configuration<?>> convertToTypedConfig(final Configuration<Json
final Optional<Configuration<?>> typedConfig = Optional.ofNullable(baiganConfigClasses.getConfigTypesByKey().get(jsonConfig.getAlias()))
.map(targetClass -> deserializeConfig(jsonConfig, targetClass));
if (typedConfig.isEmpty()) {
LOG.info("Alias {} does not match any method in a class annotated with @BaiganConfig.", jsonConfig.getAlias());
LOG.info(
"Alias [{}] in configuration source does not match any method of any @BaiganConfig interface, ignoring it.",
jsonConfig.getAlias()
);
}
return typedConfig;
}
Expand Down

0 comments on commit 6975733

Please sign in to comment.