diff --git a/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayMessageHandler.java b/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayMessageHandler.java index c3dab969860..755ae5055ad 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayMessageHandler.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayMessageHandler.java @@ -25,7 +25,6 @@ import org.jspecify.annotations.Nullable; import org.springframework.beans.factory.BeanCreationException; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.core.task.SimpleAsyncTaskExecutor; import org.springframework.integration.handler.AbstractReplyProducingMessageHandler; import org.springframework.integration.support.management.ManageableLifecycle; @@ -158,9 +157,12 @@ private void initialize() { this.gatewayProxyFactoryBean.setDefaultReplyTimeout(this.replyTimeout); } - if (getBeanFactory() instanceof ConfigurableListableBeanFactory configurableListableBeanFactory) { - configurableListableBeanFactory.initializeBean(this.gatewayProxyFactoryBean, getComponentName() + "#gpfb"); - } + this.gatewayProxyFactoryBean.setBeanName(getComponentName() + "#gpfb"); + this.gatewayProxyFactoryBean.setBeanFactory(getBeanFactory()); + this.gatewayProxyFactoryBean.setApplicationContext(getApplicationContext()); + this.gatewayProxyFactoryBean.setBeanClassLoader(getBeanClassLoader()); + this.gatewayProxyFactoryBean.afterPropertiesSet(); + try { this.exchanger = this.gatewayProxyFactoryBean.getObject(); } diff --git a/spring-integration-test/src/test/java/org/springframework/integration/test/mock/MockMessageHandlerTests.java b/spring-integration-test/src/test/java/org/springframework/integration/test/mock/MockMessageHandlerTests.java index 0c401a02235..09faadd69fa 100644 --- a/spring-integration-test/src/test/java/org/springframework/integration/test/mock/MockMessageHandlerTests.java +++ b/spring-integration-test/src/test/java/org/springframework/integration/test/mock/MockMessageHandlerTests.java @@ -36,6 +36,7 @@ import org.springframework.integration.channel.DirectChannel; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.EnableIntegration; +import org.springframework.integration.dsl.IntegrationFlow; import org.springframework.integration.endpoint.ReactiveStreamsConsumer; import org.springframework.integration.expression.ValueExpression; import org.springframework.integration.handler.ExpressionEvaluatingMessageHandler; @@ -365,6 +366,12 @@ public ReactiveMessageHandler reactiveMessageHandler() { return message -> Mono.empty(); } + // Before the fix for https://github.com/spring-projects/spring-integration/issues/10309 this test suite has failed + @Bean + IntegrationFlow flowWithGateway() { + return flow -> flow.gateway(subFlow -> subFlow.bridge()); + } + } }