From cece9afbf2282ee8dd9d270bd2dcf9099826765e Mon Sep 17 00:00:00 2001 From: abilan Date: Wed, 16 Nov 2022 11:51:11 -0500 Subject: [PATCH] Fix GatewayProxyInitAotProcessor for proper type The `GatewayProxyInitializationAotProcessor` uses mistakenly a `ProxyFactoryBean` type instead of an expected `GatewayProxyFactoryBean`. Looks like we don't need to scan for interfaces since they are properly transformed to the `AnnotationGatewayProxyFactoryBean` bean definition during AOT phase --- ...atewayProxyInitializationAotProcessor.java | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/aot/GatewayProxyInitializationAotProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/aot/GatewayProxyInitializationAotProcessor.java index d67ca376f2..fbc33bce90 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/aot/GatewayProxyInitializationAotProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/aot/GatewayProxyInitializationAotProcessor.java @@ -17,17 +17,14 @@ package org.springframework.integration.aot; import java.util.Arrays; -import java.util.List; import java.util.stream.Stream; import org.springframework.aop.framework.AopProxyUtils; -import org.springframework.aop.framework.ProxyFactoryBean; import org.springframework.aot.hint.ProxyHints; import org.springframework.beans.factory.aot.BeanFactoryInitializationAotContribution; import org.springframework.beans.factory.aot.BeanFactoryInitializationAotProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.support.RegisteredBean; -import org.springframework.core.annotation.AnnotatedElementUtils; import org.springframework.integration.annotation.MessagingGateway; import org.springframework.integration.gateway.GatewayProxyFactoryBean; import org.springframework.integration.gateway.RequestReplyExchanger; @@ -45,22 +42,11 @@ class GatewayProxyInitializationAotProcessor implements BeanFactoryInitializatio @Override public BeanFactoryInitializationAotContribution processAheadOfTime(ConfigurableListableBeanFactory beanFactory) { - List registeredBeans = + Stream> gatewayProxyInterfaces = Arrays.stream(beanFactory.getBeanDefinitionNames()) .map((beanName) -> RegisteredBean.of(beanFactory, beanName)) - .toList(); - - Stream> gatewayProxyInterfaces = - Stream.concat( - registeredBeans.stream() - .filter(bean -> ProxyFactoryBean.class.isAssignableFrom(bean.getBeanClass())) - .map((bean) -> - bean.getBeanType().getGeneric(0).resolve(RequestReplyExchanger.class)), - registeredBeans.stream() - .map(RegisteredBean::getBeanClass) - .filter(beanClass -> - beanClass.isInterface() && - AnnotatedElementUtils.hasAnnotation(beanClass, MessagingGateway.class))); + .filter((bean) -> GatewayProxyFactoryBean.class.isAssignableFrom(bean.getBeanClass())) + .flatMap((bean) -> Stream.ofNullable(bean.getBeanType().getGeneric(0).resolve())); return (generationContext, beanFactoryInitializationCode) -> { ProxyHints proxyHints = generationContext.getRuntimeHints().proxies();