Skip to content

Commit

Permalink
Reduce WARN level log output during test AOT processing
Browse files Browse the repository at this point in the history
Closes gh-30867
  • Loading branch information
sbrannen committed Jul 11, 2023
1 parent c418118 commit ad3e542
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.springframework.core.annotation.MergedAnnotation;
import org.springframework.core.annotation.MergedAnnotations;
import org.springframework.core.annotation.MergedAnnotations.SearchStrategy;
import org.springframework.core.log.LogMessage;
import org.springframework.javapoet.ClassName;
import org.springframework.test.context.BootstrapUtils;
import org.springframework.test.context.ContextLoadException;
Expand Down Expand Up @@ -195,8 +194,10 @@ private MultiValueMap<ClassName, Class<?>> processAheadOfTime(
ClassLoader classLoader = getClass().getClassLoader();
MultiValueMap<ClassName, Class<?>> initializerClassMappings = new LinkedMultiValueMap<>();
mergedConfigMappings.forEach((mergedConfig, testClasses) -> {
logger.debug(LogMessage.format("Generating AOT artifacts for test classes %s",
testClasses.stream().map(Class::getName).toList()));
if (logger.isDebugEnabled()) {
logger.debug("Generating AOT artifacts for test classes " +
testClasses.stream().map(Class::getName).toList());
}
this.mergedConfigRuntimeHints.registerHints(this.runtimeHints, mergedConfig, classLoader);
try {
// Use first test class discovered for a given unique MergedContextConfiguration.
Expand All @@ -209,8 +210,16 @@ private MultiValueMap<ClassName, Class<?>> processAheadOfTime(
generationContext.writeGeneratedContent();
}
catch (Exception ex) {
logger.warn(LogMessage.format("Failed to generate AOT artifacts for test classes %s",
testClasses.stream().map(Class::getName).toList()), ex);
if (logger.isDebugEnabled()) {
logger.debug("Failed to generate AOT artifacts for test classes " +
testClasses.stream().map(Class::getName).toList(), ex);
}
else if (logger.isWarnEnabled()) {
logger.warn("""
Failed to generate AOT artifacts for test classes %s. \
Enable DEBUG logging to view the stack trace. %s"""
.formatted(testClasses.stream().map(Class::getName).toList(), ex));
}
}
});
return initializerClassMappings;
Expand Down

0 comments on commit ad3e542

Please sign in to comment.