Skip to content

Commit cece9af

Browse files
committed
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
1 parent 2f1c202 commit cece9af

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

spring-integration-core/src/main/java/org/springframework/integration/aot/GatewayProxyInitializationAotProcessor.java

+3-17
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,14 @@
1717
package org.springframework.integration.aot;
1818

1919
import java.util.Arrays;
20-
import java.util.List;
2120
import java.util.stream.Stream;
2221

2322
import org.springframework.aop.framework.AopProxyUtils;
24-
import org.springframework.aop.framework.ProxyFactoryBean;
2523
import org.springframework.aot.hint.ProxyHints;
2624
import org.springframework.beans.factory.aot.BeanFactoryInitializationAotContribution;
2725
import org.springframework.beans.factory.aot.BeanFactoryInitializationAotProcessor;
2826
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
2927
import org.springframework.beans.factory.support.RegisteredBean;
30-
import org.springframework.core.annotation.AnnotatedElementUtils;
3128
import org.springframework.integration.annotation.MessagingGateway;
3229
import org.springframework.integration.gateway.GatewayProxyFactoryBean;
3330
import org.springframework.integration.gateway.RequestReplyExchanger;
@@ -45,22 +42,11 @@ class GatewayProxyInitializationAotProcessor implements BeanFactoryInitializatio
4542

4643
@Override
4744
public BeanFactoryInitializationAotContribution processAheadOfTime(ConfigurableListableBeanFactory beanFactory) {
48-
List<RegisteredBean> registeredBeans =
45+
Stream<? extends Class<?>> gatewayProxyInterfaces =
4946
Arrays.stream(beanFactory.getBeanDefinitionNames())
5047
.map((beanName) -> RegisteredBean.of(beanFactory, beanName))
51-
.toList();
52-
53-
Stream<Class<?>> gatewayProxyInterfaces =
54-
Stream.concat(
55-
registeredBeans.stream()
56-
.filter(bean -> ProxyFactoryBean.class.isAssignableFrom(bean.getBeanClass()))
57-
.map((bean) ->
58-
bean.getBeanType().getGeneric(0).resolve(RequestReplyExchanger.class)),
59-
registeredBeans.stream()
60-
.map(RegisteredBean::getBeanClass)
61-
.filter(beanClass ->
62-
beanClass.isInterface() &&
63-
AnnotatedElementUtils.hasAnnotation(beanClass, MessagingGateway.class)));
48+
.filter((bean) -> GatewayProxyFactoryBean.class.isAssignableFrom(bean.getBeanClass()))
49+
.flatMap((bean) -> Stream.ofNullable(bean.getBeanType().getGeneric(0).resolve()));
6450

6551
return (generationContext, beanFactoryInitializationCode) -> {
6652
ProxyHints proxyHints = generationContext.getRuntimeHints().proxies();

0 commit comments

Comments
 (0)