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 3b875da246b2a..5c8ef29854607 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 @@ -474,10 +474,10 @@ final class ReadOperation { final ConfigTrackingInterceptor buildConfigTracker; final Set processedNames = new HashSet<>(); final Map, Object> objectsByClass = new HashMap<>(); - final Map allBuildTimeValues = new TreeMap<>(); - final Map buildTimeRunTimeValues = new TreeMap<>(); - final Map runTimeDefaultValues = new TreeMap<>(); - final Map runTimeValues = new TreeMap<>(); + final Map allBuildTimeValues = new TreeMap<>(); + final Map buildTimeRunTimeValues = new TreeMap<>(); + final Map runTimeDefaultValues = new TreeMap<>(); + final Map runTimeValues = new TreeMap<>(); final Map> convByType = new HashMap<>(); @@ -538,7 +538,7 @@ ReadResult run() { if (matched instanceof FieldContainer) { ConfigValue configValue = config.getConfigValue(propertyName); if (configValue.getValue() != null) { - allBuildTimeValues.put(configValue.getNameProfiled(), configValue.getValue()); + allBuildTimeValues.put(configValue.getNameProfiled(), configValue); ni.goToEnd(); // cursor is located after group property key (if any) getGroup((FieldContainer) matched, ni); @@ -557,7 +557,7 @@ ReadResult run() { Field field = matched.findField(); Converter converter = getConverter(config, field, ConverterType.of(field)); map.put(key, config.convertValue(configValue, converter)); - allBuildTimeValues.put(configValue.getNameProfiled(), configValue.getValue()); + allBuildTimeValues.put(configValue.getNameProfiled(), configValue); } } // build time (run time visible) patterns @@ -570,8 +570,8 @@ ReadResult run() { ni.goToEnd(); // cursor is located after group property key (if any) getGroup((FieldContainer) matched, ni); - allBuildTimeValues.put(configValue.getNameProfiled(), configValue.getValue()); - buildTimeRunTimeValues.put(configValue.getNameProfiled(), configValue.getValue()); + allBuildTimeValues.put(configValue.getNameProfiled(), configValue); + buildTimeRunTimeValues.put(configValue.getNameProfiled(), configValue); } } else if (matched != null) { assert matched instanceof MapContainer; @@ -587,8 +587,8 @@ ReadResult run() { Converter converter = getConverter(config, field, ConverterType.of(field)); map.put(key, config.convertValue(configValue, converter)); // cache the resolved value - allBuildTimeValues.put(configValue.getNameProfiled(), configValue.getValue()); - buildTimeRunTimeValues.put(configValue.getNameProfiled(), configValue.getValue()); + allBuildTimeValues.put(configValue.getNameProfiled(), configValue); + buildTimeRunTimeValues.put(configValue.getNameProfiled(), configValue); } } // run time patterns @@ -599,7 +599,7 @@ ReadResult run() { // it's a run-time default (record for later) ConfigValue configValue = withoutExpansion(() -> runtimeConfig.getConfigValue(propertyName)); if (configValue.getValue() != null) { - runTimeValues.put(configValue.getNameProfiled(), configValue.getValue()); + runTimeValues.put(configValue.getNameProfiled(), configValue); } } @@ -610,7 +610,7 @@ ReadResult run() { // it's not managed by us; record it ConfigValue configValue = withoutExpansion(() -> runtimeConfig.getConfigValue(propertyName)); if (configValue.getValue() != null) { - runTimeValues.put(propertyName, configValue.getValue()); + runTimeValues.put(propertyName, configValue); } // in the case the user defined compound keys in YAML (or similar config source, that quotes the name) @@ -638,22 +638,22 @@ ReadResult run() { unknownBuildProperties.remove(property); ConfigValue value = config.getConfigValue(property); if (value.getRawValue() != null) { - allBuildTimeValues.put(value.getNameProfiled(), value.getRawValue()); + allBuildTimeValues.put(value.getNameProfiled(), value); } } if (buildTimeRunTimeNames.contains(name)) { unknownBuildProperties.remove(property); ConfigValue value = config.getConfigValue(property); if (value.getRawValue() != null) { - allBuildTimeValues.put(value.getNameProfiled(), value.getRawValue()); - buildTimeRunTimeValues.put(value.getNameProfiled(), value.getRawValue()); + allBuildTimeValues.put(value.getNameProfiled(), value); + buildTimeRunTimeValues.put(value.getNameProfiled(), value); } } if (runTimeNames.contains(name)) { unknownBuildProperties.remove(property); ConfigValue value = runtimeConfig.getConfigValue(property); if (value.getRawValue() != null) { - runTimeValues.put(value.getNameProfiled(), value.getRawValue()); + runTimeValues.put(value.getNameProfiled(), value); } } } @@ -1168,7 +1168,7 @@ public String getValue(final String propertyName) { return builder.build(); } - private Map filterActiveProfileProperties(final Map properties) { + private Map filterActiveProfileProperties(final Map properties) { Set propertiesToRemove = new HashSet<>(); for (String property : properties.keySet()) { for (String profile : config.getProfiles()) { @@ -1182,16 +1182,16 @@ private Map filterActiveProfileProperties(final Map getDefaults(final SmallRyeConfig config, + private static Map getDefaults(final SmallRyeConfig config, final ConfigPatternMap patternMap) { - Map defaultValues = new TreeMap<>(); + Map defaultValues = new TreeMap<>(); getDefaults(config, defaultValues, new StringBuilder(), patternMap); return defaultValues; } private static void getDefaults( final SmallRyeConfig config, - final Map defaultValues, + final Map defaultValues, final StringBuilder propertyName, final ConfigPatternMap patternMap) { @@ -1204,10 +1204,17 @@ private static void getDefaults( if (defaultValue != null) { // lookup config to make sure we catch relocates or fallbacks and override the value ConfigValue configValue = config.getConfigValue(propertyName.toString()); - if (configValue.getValue() != null && !configValue.getName().equals(propertyName.toString())) { - defaultValues.put(propertyName.toString(), configValue.getValue()); + if (configValue.getValue() != null && !configValue.getName().contentEquals(propertyName)) { + defaultValues.put(propertyName.toString(), configValue); } else { - defaultValues.put(propertyName.toString(), defaultValue); + defaultValues.put(propertyName.toString(), + ConfigValue.builder() + .withName(propertyName.toString()) + .withValue(defaultValue) + .withRawValue(defaultValue) + .withConfigSourceName("DefaultValuesConfigSource") + .withConfigSourceOrdinal(Integer.MIN_VALUE) + .build()); } } } @@ -1250,10 +1257,10 @@ private static Map mappingsToNames(final List public static final class ReadResult { final Map, Object> objectsByClass; - final Map allBuildTimeValues; - final Map buildTimeRunTimeValues; - final Map runTimeDefaultValues; - final Map runTimeValues; + final Map allBuildTimeValues; + final Map buildTimeRunTimeValues; + final Map runTimeDefaultValues; + final Map runTimeValues; final ConfigPatternMap buildTimePatternMap; final ConfigPatternMap buildTimeRunTimePatternMap; @@ -1327,19 +1334,19 @@ public Map, Object> getObjectsByClass() { return objectsByClass; } - public Map getAllBuildTimeValues() { + public Map getAllBuildTimeValues() { return allBuildTimeValues; } - public Map getBuildTimeRunTimeValues() { + public Map getBuildTimeRunTimeValues() { return buildTimeRunTimeValues; } - public Map getRunTimeDefaultValues() { + public Map getRunTimeDefaultValues() { return runTimeDefaultValues; } - public Map getRunTimeValues() { + public Map getRunTimeValues() { return runTimeValues; } @@ -1409,10 +1416,10 @@ public ConfigTrackingInterceptor.ReadOptionsProvider getReadOptionsProvider() { static class Builder { private Map, Object> objectsByClass; - private Map allBuildTimeValues; - private Map buildTimeRunTimeValues; - private Map runTimeDefaultValues; - private Map runtimeValues; + private Map allBuildTimeValues; + private Map buildTimeRunTimeValues; + private Map runTimeDefaultValues; + private Map runtimeValues; private ConfigPatternMap buildTimePatternMap; private ConfigPatternMap buildTimeRunTimePatternMap; private ConfigPatternMap runTimePatternMap; @@ -1433,38 +1440,38 @@ Builder setObjectsByClass(final Map, Object> objectsByClass) { return this; } - Map getAllBuildTimeValues() { + Map getAllBuildTimeValues() { return allBuildTimeValues; } - Builder setAllBuildTimeValues(final Map allBuildTimeValues) { + Builder setAllBuildTimeValues(final Map allBuildTimeValues) { this.allBuildTimeValues = allBuildTimeValues; return this; } - Map getBuildTimeRunTimeValues() { + Map getBuildTimeRunTimeValues() { return buildTimeRunTimeValues; } - Builder setBuildTimeRunTimeValues(final Map buildTimeRunTimeValues) { + Builder setBuildTimeRunTimeValues(final Map buildTimeRunTimeValues) { this.buildTimeRunTimeValues = buildTimeRunTimeValues; return this; } - Map getRunTimeDefaultValues() { + Map getRunTimeDefaultValues() { return runTimeDefaultValues; } - Builder setRunTimeDefaultValues(final Map runTimeDefaultValues) { + Builder setRunTimeDefaultValues(final Map runTimeDefaultValues) { this.runTimeDefaultValues = runTimeDefaultValues; return this; } - Map getRuntimeValues() { + Map getRuntimeValues() { return runtimeValues; } - Builder setRuntimeValues(final Map runtimeValues) { + Builder setRuntimeValues(final Map runtimeValues) { this.runtimeValues = runtimeValues; return this; } diff --git a/core/deployment/src/main/java/io/quarkus/deployment/configuration/RunTimeConfigurationGenerator.java b/core/deployment/src/main/java/io/quarkus/deployment/configuration/RunTimeConfigurationGenerator.java index 64fa6ac2e57fb..2fcfed8eea5f6 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/configuration/RunTimeConfigurationGenerator.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/configuration/RunTimeConfigurationGenerator.java @@ -224,10 +224,6 @@ public static final class GenerateOperation implements AutoCloseable { final ResultHandle clinitNameBuilder; final BuildTimeConfigurationReader.ReadResult buildTimeConfigResult; final List roots; - final Map allBuildTimeValues; - // default values given in the build configuration - final Map runTimeDefaultValues; - final Map buildTimeRunTimeValues; final Map enclosingMemberMethods = new HashMap<>(); final Map, MethodDescriptor> groupInitMethods = new HashMap<>(); final Map, FieldDescriptor> configRootsByType = new HashMap<>(); @@ -256,11 +252,6 @@ public static final class GenerateOperation implements AutoCloseable { this.liveReloadPossible = builder.liveReloadPossible; final BuildTimeConfigurationReader.ReadResult buildTimeReadResult = builder.buildTimeReadResult; buildTimeConfigResult = Assert.checkNotNullParam("buildTimeReadResult", buildTimeReadResult); - allBuildTimeValues = Assert.checkNotNullParam("allBuildTimeValues", buildTimeReadResult.getAllBuildTimeValues()); - runTimeDefaultValues = Assert.checkNotNullParam("runTimeDefaultValues", - buildTimeReadResult.getRunTimeDefaultValues()); - buildTimeRunTimeValues = Assert.checkNotNullParam("buildTimeRunTimeValues", - buildTimeReadResult.getBuildTimeRunTimeValues()); classOutput = Assert.checkNotNullParam("classOutput", builder.getClassOutput()); roots = Assert.checkNotNullParam("builder.roots", builder.getBuildTimeReadResult().getAllRoots()); additionalTypes = Assert.checkNotNullParam("additionalTypes", builder.getAdditionalTypes()); diff --git a/core/deployment/src/main/java/io/quarkus/deployment/configuration/tracker/ConfigTrackingWriter.java b/core/deployment/src/main/java/io/quarkus/deployment/configuration/tracker/ConfigTrackingWriter.java index b68be67a9f5bf..a9ae6a0c16709 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/configuration/tracker/ConfigTrackingWriter.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/configuration/tracker/ConfigTrackingWriter.java @@ -15,6 +15,7 @@ import io.quarkus.bootstrap.util.PropertyUtils; import io.quarkus.deployment.configuration.BuildTimeConfigurationReader; import io.quarkus.runtime.LaunchMode; +import io.smallrye.config.ConfigValue; public class ConfigTrackingWriter { @@ -77,8 +78,8 @@ public static void write(Map readOptions, ConfigTrackingConfig c final List excludePatterns = config.getExcludePatterns(); final ConfigTrackingValueTransformer valueTransformer = ConfigTrackingValueTransformer.newInstance(config); - final Map allBuildTimeValues = configReadResult.getAllBuildTimeValues(); - final Map buildTimeRuntimeValues = configReadResult.getBuildTimeRunTimeValues(); + final Map allBuildTimeValues = configReadResult.getAllBuildTimeValues(); + final Map buildTimeRuntimeValues = configReadResult.getBuildTimeRunTimeValues(); try (BufferedWriter writer = Files.newBufferedWriter(file)) { final List names = new ArrayList<>(readOptions.size()); for (var name : readOptions.keySet()) { diff --git a/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigGenerationBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigGenerationBuildStep.java index 090cc485a3af9..24ab9fad7b140 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigGenerationBuildStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigGenerationBuildStep.java @@ -29,9 +29,7 @@ import jakarta.annotation.Priority; -import org.eclipse.microprofile.config.Config; import org.eclipse.microprofile.config.ConfigProvider; -import org.eclipse.microprofile.config.ConfigValue; import org.eclipse.microprofile.config.spi.ConfigSource; import org.eclipse.microprofile.config.spi.ConfigSourceProvider; import org.eclipse.microprofile.config.spi.Converter; @@ -99,6 +97,7 @@ import io.smallrye.config.ConfigSourceFactory; import io.smallrye.config.ConfigSourceInterceptor; import io.smallrye.config.ConfigSourceInterceptorFactory; +import io.smallrye.config.ConfigValue; import io.smallrye.config.DefaultValuesConfigSource; import io.smallrye.config.ProfileConfigSourceInterceptor; import io.smallrye.config.SecretKeysHandler; @@ -139,8 +138,8 @@ void buildTimeRunTimeConfig( ResultHandle map = clinit.newInstance(MethodDescriptor.ofConstructor(HashMap.class)); MethodDescriptor put = MethodDescriptor.ofMethod(Map.class, "put", Object.class, Object.class, Object.class); - for (Map.Entry entry : configItem.getReadResult().getBuildTimeRunTimeValues().entrySet()) { - clinit.invokeInterfaceMethod(put, map, clinit.load(entry.getKey()), clinit.load(entry.getValue())); + for (Map.Entry entry : configItem.getReadResult().getBuildTimeRunTimeValues().entrySet()) { + clinit.invokeInterfaceMethod(put, map, clinit.load(entry.getKey()), clinit.load(entry.getValue().getValue())); } ResultHandle defaultValuesSource = clinit.newInstance( @@ -217,14 +216,20 @@ void generateBuilders( Map defaultValues = new HashMap<>(); // Default values from @ConfigRoot - defaultValues.putAll(configItem.getReadResult().getRunTimeDefaultValues()); + for (Map.Entry entry : configItem.getReadResult().getRunTimeDefaultValues().entrySet()) { + defaultValues.put(entry.getKey(), entry.getValue().getRawValue()); + } // Default values from build item RunTimeConfigurationDefaultBuildItem override for (RunTimeConfigurationDefaultBuildItem e : runTimeDefaults) { defaultValues.put(e.getKey(), e.getValue()); } // Recorded values from build time from any other source (higher ordinal then defaults, so override) - List profiles = ConfigProvider.getConfig().unwrap(SmallRyeConfig.class).getProfiles(); - for (Map.Entry entry : configItem.getReadResult().getRunTimeValues().entrySet()) { + SmallRyeConfig config = ConfigProvider.getConfig().unwrap(SmallRyeConfig.class); + List profiles = config.getProfiles(); + for (Map.Entry entry : configItem.getReadResult().getRunTimeValues().entrySet()) { + if ("DefaultValuesConfigSource".equals(entry.getValue().getConfigSourceName())) { + continue; + } // Runtime values may contain active profiled names that override sames names in defaults // We need to keep the original name definition in case a different profile is used to run the app String activeName = ProfileConfigSourceInterceptor.activeName(entry.getKey(), profiles); @@ -232,9 +237,8 @@ void generateBuilders( if (!configItem.getReadResult().getRunTimeDefaultValues().containsKey(activeName)) { defaultValues.remove(activeName); } - defaultValues.put(entry.getKey(), entry.getValue()); + defaultValues.put(entry.getKey(), entry.getValue().getRawValue()); } - defaultValues.putAll(configItem.getReadResult().getRunTimeValues()); Set converters = discoverService(Converter.class, reflectiveClass); Set interceptors = discoverService(ConfigSourceInterceptor.class, reflectiveClass); @@ -358,28 +362,25 @@ public void checkForBuildTimeConfigChange( recorderContext.registerSubstitution(io.smallrye.config.ConfigValue.class, QuarkusConfigValue.class, QuarkusConfigValue.Substitution.class); - BuildTimeConfigurationReader.ReadResult readResult = configItem.getReadResult(); - Config config = ConfigProvider.getConfig(); - Set excludedConfigKeys = new HashSet<>(suppressNonRuntimeConfigChangedWarningItems.size()); for (SuppressNonRuntimeConfigChangedWarningBuildItem item : suppressNonRuntimeConfigChangedWarningItems) { excludedConfigKeys.add(item.getConfigKey()); } Map values = new HashMap<>(); - - for (final Map.Entry entry : readResult.getAllBuildTimeValues().entrySet()) { + BuildTimeConfigurationReader.ReadResult readResult = configItem.getReadResult(); + for (final Map.Entry entry : readResult.getAllBuildTimeValues().entrySet()) { if (excludedConfigKeys.contains(entry.getKey())) { continue; } - values.putIfAbsent(entry.getKey(), config.getConfigValue(entry.getKey())); + values.putIfAbsent(entry.getKey(), entry.getValue()); } - for (Map.Entry entry : readResult.getBuildTimeRunTimeValues().entrySet()) { + for (Map.Entry entry : readResult.getBuildTimeRunTimeValues().entrySet()) { if (excludedConfigKeys.contains(entry.getKey())) { continue; } - values.put(entry.getKey(), config.getConfigValue(entry.getKey())); + values.put(entry.getKey(), entry.getValue()); } recorder.handleConfigChange(values); diff --git a/core/runtime/src/main/java/io/quarkus/runtime/configuration/ConfigRecorder.java b/core/runtime/src/main/java/io/quarkus/runtime/configuration/ConfigRecorder.java index 870c5c7041f27..fbade91a5891f 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/configuration/ConfigRecorder.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/configuration/ConfigRecorder.java @@ -11,12 +11,12 @@ import java.util.Optional; import org.eclipse.microprofile.config.ConfigProvider; -import org.eclipse.microprofile.config.ConfigValue; import org.eclipse.microprofile.config.spi.ConfigSource; import org.jboss.logging.Logger; import io.quarkus.runtime.ShutdownContext; import io.quarkus.runtime.annotations.Recorder; +import io.smallrye.config.ConfigValue; import io.smallrye.config.SmallRyeConfig; @Recorder diff --git a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/AbstractDevUIProcessor.java b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/AbstractDevUIProcessor.java index 1385aa5929874..6d6f2ae31ad8d 100644 --- a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/AbstractDevUIProcessor.java +++ b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/AbstractDevUIProcessor.java @@ -15,6 +15,7 @@ import io.quarkus.runtime.RuntimeValue; import io.quarkus.vertx.http.deployment.NonApplicationRootPathBuildItem; import io.quarkus.vertx.http.runtime.HttpConfiguration; +import io.smallrye.config.ConfigValue; public abstract class AbstractDevUIProcessor { protected static final String CONFIG_PREFIX = "quarkus.oidc."; @@ -88,27 +89,27 @@ private static String getProperty(ConfigurationBuildItem configurationBuildItem, // but I wanted to make this bit more robust till we have DEV UI tests // that will fail when this get changed in the future, then we can optimize this - String propertyValue = configurationBuildItem + ConfigValue configValue = configurationBuildItem .getReadResult() .getAllBuildTimeValues() .get(propertyKey); - if (propertyValue == null) { - propertyValue = configurationBuildItem + if (configValue == null || configValue.getValue() == null) { + configValue = configurationBuildItem .getReadResult() .getBuildTimeRunTimeValues() .get(propertyKey); } else { - return propertyValue; + return configValue.getValue(); } - if (propertyValue == null) { - propertyValue = configurationBuildItem + if (configValue == null || configValue.getValue() == null) { + configValue = configurationBuildItem .getReadResult() .getRunTimeDefaultValues() .get(propertyKey); } - return propertyValue; + return configValue != null ? configValue.getValue() : null; } } diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/menu/EndpointsProcessor.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/menu/EndpointsProcessor.java index 47e3e8c0ccd1a..0b051f9ab7874 100644 --- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/menu/EndpointsProcessor.java +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/menu/EndpointsProcessor.java @@ -10,6 +10,7 @@ import io.quarkus.devui.spi.page.Page; import io.quarkus.vertx.http.deployment.NonApplicationRootPathBuildItem; import io.quarkus.vertx.http.runtime.devmode.ResourceNotFoundData; +import io.smallrye.config.ConfigValue; /** * This creates Endpoints Page @@ -62,27 +63,27 @@ JsonRPCProvidersBuildItem createJsonRPCService() { private static String getProperty(ConfigurationBuildItem configurationBuildItem, String propertyKey) { - String propertyValue = configurationBuildItem + ConfigValue configValue = configurationBuildItem .getReadResult() .getAllBuildTimeValues() .get(propertyKey); - if (propertyValue == null) { - propertyValue = configurationBuildItem + if (configValue == null || configValue.getValue() == null) { + configValue = configurationBuildItem .getReadResult() .getBuildTimeRunTimeValues() .get(propertyKey); } else { - return propertyValue; + return configValue.getValue(); } - if (propertyValue == null) { - propertyValue = configurationBuildItem + if (configValue == null || configValue.getValue() == null) { + configValue = configurationBuildItem .getReadResult() .getRunTimeDefaultValues() .get(propertyKey); } - return propertyValue; + return configValue != null ? configValue.getValue() : null; } } diff --git a/integration-tests/test-extension/extension/deployment/src/main/java/io/quarkus/extest/deployment/TestProcessor.java b/integration-tests/test-extension/extension/deployment/src/main/java/io/quarkus/extest/deployment/TestProcessor.java index 78308d1105841..c2928977d26d2 100644 --- a/integration-tests/test-extension/extension/deployment/src/main/java/io/quarkus/extest/deployment/TestProcessor.java +++ b/integration-tests/test-extension/extension/deployment/src/main/java/io/quarkus/extest/deployment/TestProcessor.java @@ -17,6 +17,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Base64; +import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Objects; @@ -72,6 +73,7 @@ import io.quarkus.extest.runtime.subst.KeyProxy; import io.quarkus.runtime.RuntimeValue; import io.quarkus.undertow.deployment.ServletBuildItem; +import io.smallrye.config.ConfigValue; /** * A test extension deployment processor @@ -337,8 +339,14 @@ void configMapping(BuildProducer configProperties, ConfigurationBuildItem configItem, TestMappingBuildTime testMappingBuildTime, TestMappingBuildTimeRunTime testMappingBuildTimeRunTime) { - Map buildTimeValues = configItem.getReadResult().getAllBuildTimeValues(); - Map buildTimeRunTimeValues = configItem.getReadResult().getBuildTimeRunTimeValues(); + Map buildTimeValues = new HashMap<>(); + for (Map.Entry entry : configItem.getReadResult().getAllBuildTimeValues().entrySet()) { + buildTimeValues.put(entry.getKey(), entry.getValue().getValue()); + } + Map buildTimeRunTimeValues = new HashMap<>(); + for (Map.Entry entry : configItem.getReadResult().getBuildTimeRunTimeValues().entrySet()) { + buildTimeRunTimeValues.put(entry.getKey(), entry.getValue().getValue()); + } if (!testMappingBuildTime.value().equals("value") || !buildTimeValues.getOrDefault("quarkus.mapping.bt.value", "").equals("value")) { diff --git a/integration-tests/test-extension/extension/deployment/src/test/java/io/quarkus/extest/OverrideBuildDefaultInRuntimeTest.java b/integration-tests/test-extension/extension/deployment/src/test/java/io/quarkus/extest/OverrideBuildDefaultInRuntimeTest.java new file mode 100644 index 0000000000000..248b3c185efca --- /dev/null +++ b/integration-tests/test-extension/extension/deployment/src/test/java/io/quarkus/extest/OverrideBuildDefaultInRuntimeTest.java @@ -0,0 +1,31 @@ +package io.quarkus.extest; + +import static org.junit.jupiter.api.Assertions.assertFalse; + +import org.eclipse.microprofile.config.ConfigProvider; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.builder.BuildContext; +import io.quarkus.builder.BuildStep; +import io.quarkus.deployment.builditem.RunTimeConfigurationDefaultBuildItem; +import io.quarkus.test.QuarkusUnitTest; + +public class OverrideBuildDefaultInRuntimeTest { + @RegisterExtension + static final QuarkusUnitTest TEST = new QuarkusUnitTest() + .withEmptyApplication() + .addBuildChainCustomizer(b -> { + b.addBuildStep(new BuildStep() { + @Override + public void execute(BuildContext context) { + context.produce(new RunTimeConfigurationDefaultBuildItem("quarkus.log.console.enable", "false")); + } + }).produces(RunTimeConfigurationDefaultBuildItem.class).build(); + }); + + @Test + public void testConsoleLogging() { + assertFalse(ConfigProvider.getConfig().getValue("quarkus.log.console.enable", boolean.class)); + } +}