From 2cd5f4520f3488cb2f075959dda14e4b5b271c0d Mon Sep 17 00:00:00 2001 From: Lukas Niemeier Date: Thu, 8 Feb 2024 10:05:24 +0100 Subject: [PATCH] clarified log messages on configuration mismatches --- ...textAwareConfigurationMethodInvocationHandler.java | 2 +- .../baigan/repository/ConfigurationParser.java | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/zalando/baigan/proxy/handler/ContextAwareConfigurationMethodInvocationHandler.java b/src/main/java/org/zalando/baigan/proxy/handler/ContextAwareConfigurationMethodInvocationHandler.java index f27565a..58b9421 100644 --- a/src/main/java/org/zalando/baigan/proxy/handler/ContextAwareConfigurationMethodInvocationHandler.java +++ b/src/main/java/org/zalando/baigan/proxy/handler/ContextAwareConfigurationMethodInvocationHandler.java @@ -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)) { diff --git a/src/main/java/org/zalando/baigan/repository/ConfigurationParser.java b/src/main/java/org/zalando/baigan/repository/ConfigurationParser.java index 3ab5acf..5f830a3 100644 --- a/src/main/java/org/zalando/baigan/repository/ConfigurationParser.java +++ b/src/main/java/org/zalando/baigan/repository/ConfigurationParser.java @@ -49,12 +49,6 @@ public List> parseConfigurations(final String text) { .collect(toList()); } - public Optional> parseConfiguration(final String text) { - Optional> rawConfig = parseConfigText(text, new TypeReference<>() { - }); - return rawConfig.flatMap(this::convertToTypedConfig); - } - private Optional parseConfigText(final String text, TypeReference type) { if (text == null || text.isEmpty()) { LOG.warn("Input to parse is empty: {}", text); @@ -75,7 +69,10 @@ private Optional> convertToTypedConfig(final 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; }