From aa83bbee3d6b0f78eedf7385f60c838b86ed26be Mon Sep 17 00:00:00 2001 From: arefbehboudi Date: Tue, 3 Sep 2024 12:27:39 +0330 Subject: [PATCH 1/2] Polish See gh-42095 --- ...vletComponentRegisteringPostProcessor.java | 30 ++++++++----------- .../web/servlet/support/ErrorPageFilter.java | 4 +-- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletComponentRegisteringPostProcessor.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletComponentRegisteringPostProcessor.java index 6494d931a2a..9bb266a887a 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletComponentRegisteringPostProcessor.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletComponentRegisteringPostProcessor.java @@ -121,26 +121,20 @@ class ServletComponentRegisteringPostProcessor @Override public BeanFactoryInitializationAotContribution processAheadOfTime(ConfigurableListableBeanFactory beanFactory) { - return new BeanFactoryInitializationAotContribution() { - - @Override - public void applyTo(GenerationContext generationContext, - BeanFactoryInitializationCode beanFactoryInitializationCode) { - for (String beanName : beanFactory.getBeanDefinitionNames()) { - BeanDefinition definition = beanFactory.getBeanDefinition(beanName); - if (Objects.equals(definition.getBeanClassName(), - WebListenerHandler.ServletComponentWebListenerRegistrar.class.getName())) { - String listenerClassName = (String) definition.getConstructorArgumentValues() - .getArgumentValue(0, String.class) - .getValue(); - generationContext.getRuntimeHints() - .reflection() - .registerType(TypeReference.of(listenerClassName), - MemberCategory.INVOKE_DECLARED_CONSTRUCTORS); - } + return (generationContext, beanFactoryInitializationCode) -> { + for (String beanName : beanFactory.getBeanDefinitionNames()) { + BeanDefinition definition = beanFactory.getBeanDefinition(beanName); + if (Objects.equals(definition.getBeanClassName(), + WebListenerHandler.ServletComponentWebListenerRegistrar.class.getName())) { + String listenerClassName = (String) definition.getConstructorArgumentValues() + .getArgumentValue(0, String.class) + .getValue(); + generationContext.getRuntimeHints() + .reflection() + .registerType(TypeReference.of(listenerClassName), + MemberCategory.INVOKE_DECLARED_CONSTRUCTORS); } } - }; } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/ErrorPageFilter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/ErrorPageFilter.java index d1a615718cc..761cfbb17cd 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/ErrorPageFilter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/ErrorPageFilter.java @@ -321,12 +321,12 @@ public class ErrorPageFilter implements Filter, ErrorPageRegistry, Ordered { } @Override - public void sendError(int status) throws IOException { + public void sendError(int status) { sendError(status, null); } @Override - public void sendError(int status, String message) throws IOException { + public void sendError(int status, String message) { this.status = status; this.message = message; this.hasErrorToSend = true; From 55f2af1279cbcf2cf105af11a2b98a249611e772 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 3 Sep 2024 14:56:14 +0100 Subject: [PATCH 2/2] Polish "Polish" See gh-42095 --- .../servlet/ServletComponentRegisteringPostProcessor.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletComponentRegisteringPostProcessor.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletComponentRegisteringPostProcessor.java index 9bb266a887a..646b02aebb4 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletComponentRegisteringPostProcessor.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletComponentRegisteringPostProcessor.java @@ -22,14 +22,12 @@ import java.util.List; import java.util.Objects; import java.util.Set; -import org.springframework.aot.generate.GenerationContext; import org.springframework.aot.hint.MemberCategory; import org.springframework.aot.hint.TypeReference; import org.springframework.beans.BeansException; import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; import org.springframework.beans.factory.aot.BeanFactoryInitializationAotContribution; import org.springframework.beans.factory.aot.BeanFactoryInitializationAotProcessor; -import org.springframework.beans.factory.aot.BeanFactoryInitializationCode; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; @@ -131,8 +129,7 @@ class ServletComponentRegisteringPostProcessor .getValue(); generationContext.getRuntimeHints() .reflection() - .registerType(TypeReference.of(listenerClassName), - MemberCategory.INVOKE_DECLARED_CONSTRUCTORS); + .registerType(TypeReference.of(listenerClassName), MemberCategory.INVOKE_DECLARED_CONSTRUCTORS); } } };