From 3559c94c91f3fa6bf3db693d20db05a160758160 Mon Sep 17 00:00:00 2001 From: "David M. Lloyd" Date: Wed, 17 Apr 2024 08:01:35 -0500 Subject: [PATCH] Prevent double-warning when using deprecated properties Fixes #40047 --- .../BuildTimeConfigurationReader.java | 2 ++ .../configuration/ConfigCompatibility.java | 24 +++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/core/deployment/src/main/java/io/quarkus/deployment/configuration/BuildTimeConfigurationReader.java b/core/deployment/src/main/java/io/quarkus/deployment/configuration/BuildTimeConfigurationReader.java index 8b0cb7c4b1076b..62ef5f74e30430 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/configuration/BuildTimeConfigurationReader.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/configuration/BuildTimeConfigurationReader.java @@ -1086,6 +1086,7 @@ public String getValue(final String propertyName) { builder.getSources().clear(); builder.getSourceProviders().clear(); builder.setAddDefaultSources(false) + .withInterceptors(ConfigCompatibility.FrontEnd.nonLoggingInstance(), ConfigCompatibility.BackEnd.instance()) .addDiscoveredCustomizers() .withProfiles(config.getProfiles()) .withSources(sourceProperties); @@ -1099,6 +1100,7 @@ public String getValue(final String propertyName) { builder.getSources().clear(); builder.getSourceProviders().clear(); builder.setAddDefaultSources(false) + .withInterceptors(ConfigCompatibility.FrontEnd.nonLoggingInstance(), ConfigCompatibility.BackEnd.instance()) .addDiscoveredCustomizers() .withSources(sourceProperties) .withSources(new MapBackedConfigSource( diff --git a/core/deployment/src/main/java/io/quarkus/deployment/configuration/ConfigCompatibility.java b/core/deployment/src/main/java/io/quarkus/deployment/configuration/ConfigCompatibility.java index 54007f07a354ff..20b1853ae0c171 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/configuration/ConfigCompatibility.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/configuration/ConfigCompatibility.java @@ -114,9 +114,13 @@ public static final class FrontEnd implements ConfigSourceInterceptor { @Serial private static final long serialVersionUID = -3438497970389074611L; - private static final FrontEnd instance = new FrontEnd(); + private static final FrontEnd instance = new FrontEnd(true); + private static final FrontEnd nonLoggingInstance = new FrontEnd(false); - private FrontEnd() { + private final boolean logging; + + private FrontEnd(final boolean logging) { + this.logging = logging; } public ConfigValue getValue(final ConfigSourceInterceptorContext context, final String name) { @@ -155,11 +159,13 @@ public boolean hasNext() { // get the replacement names List list = fn.apply(context, new NameIterator(next)); subIter = list.iterator(); - // todo: print these warnings when mapping the configuration so they cannot appear more than once - if (list.isEmpty()) { - log.warnf("Configuration property '%s' has been deprecated and will be ignored", next); - } else { - log.warnf("Configuration property '%s' has been deprecated and replaced by: %s", next, list); + if (logging) { + // todo: print these warnings when mapping the configuration so they cannot appear more than once + if (list.isEmpty()) { + log.warnf("Configuration property '%s' has been deprecated and will be ignored", next); + } else { + log.warnf("Configuration property '%s' has been deprecated and replaced by: %s", next, list); + } } } return true; @@ -179,6 +185,10 @@ public String next() { public static FrontEnd instance() { return instance; } + + public static FrontEnd nonLoggingInstance() { + return nonLoggingInstance; + } } /**