8000 fix: hide runtime defaults during Quarkus dev mode augmentation by sachinnn99 · Pull Request #47743 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.keycloak.quarkus.runtime.configuration.NestedPropertyMappingInterceptor;
import org.keycloak.quarkus.runtime.configuration.PersistedConfigSource;

import io.quarkus.runtime.LaunchMode;
import io.smallrye.config.ConfigSourceInterceptorContext;
import io.smallrye.config.ConfigValue;
import io.smallrye.config.Expressions;
Expand Down Expand Up @@ -89,6 +90,11 @@ public static ConfigValue getValue(ConfigSourceInterceptorContext context, Strin
return ConfigValue.builder().withName(name).build();
}

// In Quarkus dev mode, also hide runtime defaults during augmentation probing (fixes #47659)
if (LaunchMode.current() == LaunchMode.DEVELOPMENT && !Expressions.isEnabled() && isKeycloakRuntime(name, mapper)) {
return ConfigValue.builder().withName(name).build();
}

if (mapper == null) {
return context.proceed(name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.keycloak.spi.infinispan.CacheEmbeddedConfigProviderSpi;
import org.keycloak.spi.infinispan.impl.embedded.DefaultCacheEmbeddedConfigProviderFactory;

import io.quarkus.runtime.LaunchMode;
import io.smallrye.config.ConfigValue;
import io.smallrye.config.Expressions;
import io.smallrye.config.PropertiesConfigSource;
Expand Down Expand Up @@ -108,6 +109,21 @@ public void testKeycloakConfPlaceholder() {
assertNull(Expressions.withoutExpansion(() -> Configuration.getConfigValue("kc.log-level")).getValue());
}

@Test
public void testDevModeAugmentationHidesRuntimeDefaults() {
ConfigArgsConfigSource.setCliArgs("--log-console-output=default");
createConfig();
LaunchMode.set(LaunchMode.DEVELOPMENT);
try {
// runtime values should be hidden when Quarkus probes for defaults during dev-mode augmentation
assertNull(Expressions.withoutExpansion(() -> Configuration.getConfigValue("kc.log-console-output")).getValue());
// but visible during normal dev-mode runtime (expressions enabled)
assertNotNull(Configuration.getConfigValue("kc.log-console-output").getValue());
} finally {
LaunchMode.set(LaunchMode.NORMAL);
}
}

@Test
public void testEnvVarAvailableFromPropertyNames() {
putEnvVar("KC_VAULT_DIR", "/foo/bar");
Expand Down
0