From ee362078b89815efd86c7c87c66c247a6b0cec0f Mon Sep 17 00:00:00 2001 From: Roberto Cortez Date: Wed, 11 Oct 2023 10:41:12 +0100 Subject: [PATCH] Do not exclude properties from recording that are available in sources that should always be included --- .../BuildTimeConfigurationReader.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 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 24e2225342d3b..c3ef229b00ead 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 @@ -1018,28 +1018,40 @@ private Converter getConverter(SmallRyeConfig config, Field field, ConverterT */ private Set getAllProperties(final Set registeredRoots) { Set properties = new HashSet<>(); + + // Get all properties, including the ones generated by interceptors, but these do not include profiles for (String property : config.getPropertyNames()) { properties.add(property); } + Set propertiesToRemove = new HashSet<>(); + Set propertiesToAdd = new HashSet<>(); + + // Get properties per source to collect profiled properties and exclude properties that are build related for (ConfigSource configSource : config.getConfigSources()) { if (configSource instanceof SysPropConfigSource || configSource instanceof EnvConfigSource || "PropertiesConfigSource[source=Build system]".equals(configSource.getName())) { for (String property : configSource.getPropertyNames()) { NameIterator ni = new NameIterator(property); if (ni.hasNext() && PropertiesUtil.isPropertyInRoot(registeredRoots, ni)) { - properties.add(property); + propertiesToAdd.add(property); } else { - properties.remove(property); + propertiesToRemove.add(property); if (configSource instanceof EnvConfigSource) { - properties.remove(StringUtil.toLowerCaseAndDotted(property)); + propertiesToRemove.add(StringUtil.toLowerCaseAndDotted(property)); } } } } else { - properties.addAll(configSource.getPropertyNames()); + propertiesToAdd.addAll(configSource.getPropertyNames()); } } + + // A property may exist in an excluded source and an include source. We don't have a way to know, so we + // just remove the excluded ones and add the ones to be included, so the property is back there again + properties.removeAll(propertiesToRemove); + properties.addAll(propertiesToAdd); + return properties; }