From 8e045492ef5b1bde5a821f93cd0a1e94e3c82fcf Mon Sep 17 00:00:00 2001 From: Roberto Cortez Date: Mon, 18 Nov 2024 10:39:22 +0000 Subject: [PATCH] Fix flaky test OverrideBuildTimeConfigTest --- .../main/java/io/quarkus/runtime/ConfigConfig.java | 2 +- .../runtime/configuration/ConfigRecorder.java | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/core/runtime/src/main/java/io/quarkus/runtime/ConfigConfig.java b/core/runtime/src/main/java/io/quarkus/runtime/ConfigConfig.java index 8901b6d54fac8..bec67d5c4308a 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/ConfigConfig.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/ConfigConfig.java @@ -68,7 +68,7 @@ public interface ConfigConfig { * If this is set to {@code fail} the application will fail at start up. *

* Native tests leveraging@io.quarkus.test.junit.TestProfile are always run with - * {@code quarkus.configuration.build-time-mismatch-at-runtime = fail}. + * {@code quarkus.config.build-time-mismatch-at-runtime = fail}. */ @WithName("config.build-time-mismatch-at-runtime") @WithDefault("warn") 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 baadb1c69ef2d..809fec912d362 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 @@ -1,5 +1,6 @@ package io.quarkus.runtime.configuration; +import static io.quarkus.runtime.ConfigConfig.BuildTimeMismatchAtRuntime; import static io.quarkus.runtime.ConfigConfig.BuildTimeMismatchAtRuntime.fail; import static io.quarkus.runtime.ConfigConfig.BuildTimeMismatchAtRuntime.warn; @@ -14,7 +15,6 @@ import org.eclipse.microprofile.config.spi.ConfigSource; import org.jboss.logging.Logger; -import io.quarkus.runtime.ConfigConfig; import io.quarkus.runtime.ShutdownContext; import io.quarkus.runtime.annotations.Recorder; import io.smallrye.config.SmallRyeConfig; @@ -60,14 +60,12 @@ public void handleConfigChange(Map buildTimeRuntimeValues) if (!mismatches.isEmpty()) { String msg = "Build time property cannot be changed at runtime:\n" + String.join("\n", mismatches); - SmallRyeConfig quarkusConfig = new QuarkusConfigFactory().getConfigFor(null, null); - if (!config.equals(quarkusConfig)) { - throw new IllegalStateException("SmallRyeConfig Classloaders mismatch!"); - } - ConfigConfig configConfig = quarkusConfig.getConfigMapping(ConfigConfig.class); - if (fail.equals(configConfig.buildTimeMismatchAtRuntime())) { + // TODO - This should use ConfigConfig, but for some reason, the test fails sometimes with mapping not found when looking ConfigConfig + BuildTimeMismatchAtRuntime buildTimeMismatchAtRuntime = config + .getValue("quarkus.config.build-time-mismatch-at-runtime", BuildTimeMismatchAtRuntime.class); + if (fail.equals(buildTimeMismatchAtRuntime)) { throw new IllegalStateException(msg); - } else if (warn.equals(configConfig.buildTimeMismatchAtRuntime())) { + } else if (warn.equals(buildTimeMismatchAtRuntime)) { log.warn(msg); } }