From 82b514bfa05338af898993135d5ff22b00a959e4 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Tue, 19 Jul 2022 11:57:30 +0200 Subject: [PATCH] Do not pass RuntimeValue's to initializeBuildTimeLogging Despite being part of the recorder, it is called statically at build time. We need to be extremely careful about it. Fixes #26773 (cherry picked from commit d125cd8018dfb07b94bd4807db79468322a78b1f) --- .../deployment/logging/LoggingResourceProcessor.java | 2 +- .../io/quarkus/runtime/logging/LoggingSetupRecorder.java | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/deployment/src/main/java/io/quarkus/deployment/logging/LoggingResourceProcessor.java b/core/deployment/src/main/java/io/quarkus/deployment/logging/LoggingResourceProcessor.java index 0045e8e8cbada..7501e18b0879d 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/logging/LoggingResourceProcessor.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/logging/LoggingResourceProcessor.java @@ -237,7 +237,7 @@ LoggingSetupBuildItem setupLoggingRuntimeInit(RecorderContext context, LoggingSe ConsoleRuntimeConfig crc = new ConsoleRuntimeConfig(); ConfigInstantiator.handleObject(crc); LoggingSetupRecorder.initializeBuildTimeLogging(logConfig, buildLog, categoryMinLevelDefaults.content, - crc, possibleFileFormatters, launchModeBuildItem.getLaunchMode()); + crc, launchModeBuildItem.getLaunchMode()); ((QuarkusClassLoader) Thread.currentThread().getContextClassLoader()).addCloseTask(new Runnable() { @Override public void run() { diff --git a/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java b/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java index b0e0659fc2c20..80e018bcc4bf8 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java @@ -234,9 +234,13 @@ public void accept(String categoryName, CategoryConfig config) { InitialConfigurator.DELAYED_HANDLER.setHandlers(handlers.toArray(EmbeddedConfigurator.NO_HANDLERS)); } + /** + * WARNING: this method is part of the recorder but is actually called statically at build time. + * You may not push RuntimeValue's to it. + */ public static void initializeBuildTimeLogging(LogConfig config, LogBuildTimeConfig buildConfig, Map categoryDefaultMinLevels, - ConsoleRuntimeConfig consoleConfig, List>> possibleFileFormatters, + ConsoleRuntimeConfig consoleConfig, LaunchMode launchMode) { final Map categories = config.categories; @@ -266,7 +270,7 @@ public static void initializeBuildTimeLogging(LogConfig config, LogBuildTimeConf Map namedHandlers = createNamedHandlers(config, consoleConfig, Collections.emptyList(), Collections.emptyList(), - possibleFileFormatters, errorManager, logCleanupFilter, launchMode); + Collections.emptyList(), errorManager, logCleanupFilter, launchMode); for (Map.Entry entry : categories.entrySet()) { final String categoryName = entry.getKey();