From 1af5994d8f48f1e4eec0fa46639c4940cf550bdb Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 5 Aug 2022 10:39:36 +0200 Subject: [PATCH] Adapt to API change in Spring Framework See https://github.com/spring-projects/spring-framework/issues/28927 --- .../web/server/ChildManagementContextInitializer.java | 2 +- .../web/server/ChildManagementContextInitializerAotTests.java | 2 +- .../src/main/java/org/springframework/boot/AotProcessor.java | 3 +-- ...nfigurationPropertiesBeanRegistrationAotProcessorTests.java | 3 +-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ChildManagementContextInitializer.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ChildManagementContextInitializer.java index 16b530ffa70..774322168eb 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ChildManagementContextInitializer.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ChildManagementContextInitializer.java @@ -163,7 +163,7 @@ class ChildManagementContextInitializer public void applyTo(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode) { GenerationContext managementGenerationContext = generationContext.withName("Management"); ClassName generatedInitializerClassName = new ApplicationContextAotGenerator() - .generateApplicationContext(this.managementContext, managementGenerationContext); + .processAheadOfTime(this.managementContext, managementGenerationContext); GeneratedMethod postProcessorMethod = beanRegistrationCode.getMethods().add("addManagementInitializer", (method) -> method.addJavadoc("Use AOT management context initialization") .addModifiers(Modifier.PRIVATE, Modifier.STATIC) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/ChildManagementContextInitializerAotTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/ChildManagementContextInitializerAotTests.java index a71bb0ff415..5b975ee428b 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/ChildManagementContextInitializerAotTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/ChildManagementContextInitializerAotTests.java @@ -75,7 +75,7 @@ class ChildManagementContextInitializerAotTests { EndpointAutoConfiguration.class)); contextRunner.withPropertyValues("server.port=0", "management.server.port=0").prepare((context) -> { TestGenerationContext generationContext = new TestGenerationContext(TestTarget.class); - ClassName className = new ApplicationContextAotGenerator().generateApplicationContext( + ClassName className = new ApplicationContextAotGenerator().processAheadOfTime( (GenericApplicationContext) context.getSourceApplicationContext(), generationContext); generationContext.writeGeneratedContent(); TestCompiler compiler = TestCompiler.forSystem(); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/AotProcessor.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/AotProcessor.java index 264fe63f43a..6e6122f894b 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/AotProcessor.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/AotProcessor.java @@ -147,8 +147,7 @@ public class AotProcessor { DefaultGenerationContext generationContext = new DefaultGenerationContext( new ClassNameGenerator(this.application), generatedFiles); ApplicationContextAotGenerator generator = new ApplicationContextAotGenerator(); - ClassName generatedInitializerClassName = generator.generateApplicationContext(applicationContext, - generationContext); + ClassName generatedInitializerClassName = generator.processAheadOfTime(applicationContext, generationContext); registerEntryPointHint(generationContext, generatedInitializerClassName); generationContext.writeGeneratedContent(); writeHints(generationContext.getRuntimeHints()); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBeanRegistrationAotProcessorTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBeanRegistrationAotProcessorTests.java index ead75109b85..a9c7a521e88 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBeanRegistrationAotProcessorTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBeanRegistrationAotProcessorTests.java @@ -143,8 +143,7 @@ class ConfigurationPropertiesBeanRegistrationAotProcessorTests { @SuppressWarnings("unchecked") private void compile(GenericApplicationContext context, Consumer freshContext) { TestGenerationContext generationContext = new TestGenerationContext(TestTarget.class); - ClassName className = new ApplicationContextAotGenerator().generateApplicationContext(context, - generationContext); + ClassName className = new ApplicationContextAotGenerator().processAheadOfTime(context, generationContext); generationContext.writeGeneratedContent(); TestCompiler.forSystem().withFiles(generationContext.getGeneratedFiles()).compile((compiled) -> { GenericApplicationContext freshApplicationContext = new GenericApplicationContext();