46
46
import org .springframework .core .annotation .MergedAnnotation ;
47
47
import org .springframework .core .annotation .MergedAnnotations ;
48
48
import org .springframework .core .annotation .MergedAnnotations .SearchStrategy ;
49
- import org .springframework .core .log .LogMessage ;
50
49
import org .springframework .javapoet .ClassName ;
51
50
import org .springframework .test .context .BootstrapUtils ;
52
51
import org .springframework .test .context .ContextLoadException ;
@@ -195,8 +194,10 @@ private MultiValueMap<ClassName, Class<?>> processAheadOfTime(
195
194
ClassLoader classLoader = getClass ().getClassLoader ();
196
195
MultiValueMap <ClassName , Class <?>> initializerClassMappings = new LinkedMultiValueMap <>();
197
196
mergedConfigMappings .forEach ((mergedConfig , testClasses ) -> {
198
- logger .debug (LogMessage .format ("Generating AOT artifacts for test classes %s" ,
199
- testClasses .stream ().map (Class ::getName ).toList ()));
197
+ if (logger .isDebugEnabled ()) {
198
+ logger .debug ("Generating AOT artifacts for test classes " +
199
+ testClasses .stream ().map (Class ::getName ).toList ());
200
+ }
200
201
this .mergedConfigRuntimeHints .registerHints (this .runtimeHints , mergedConfig , classLoader );
201
202
try {
202
203
// Use first test class discovered for a given unique MergedContextConfiguration.
@@ -209,8 +210,16 @@ private MultiValueMap<ClassName, Class<?>> processAheadOfTime(
209
210
generationContext .writeGeneratedContent ();
210
211
}
211
212
catch (Exception ex ) {
212
- logger .warn (LogMessage .format ("Failed to generate AOT artifacts for test classes %s" ,
213
- testClasses .stream ().map (Class ::getName ).toList ()), ex );
213
+ if (logger .isDebugEnabled ()) {
214
+ logger .debug ("Failed to generate AOT artifacts for test classes " +
215
+ testClasses .stream ().map (Class ::getName ).toList (), ex );
216
+ }
217
+ else if (logger .isWarnEnabled ()) {
218
+ logger .warn ("""
219
+ Failed to generate AOT artifacts for test classes %s. \
220
+ Enable DEBUG logging to view the stack trace. %s"""
221
+ .formatted (testClasses .stream ().map (Class ::getName ).toList (), ex ));
222
+ }
214
223
}
215
224
});
216
225
return initializerClassMappings ;
0 commit comments