diff --git a/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayProxyFactoryBean.java b/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayProxyFactoryBean.java index 120eec8630..94e946d8dc 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayProxyFactoryBean.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayProxyFactoryBean.java @@ -62,7 +62,6 @@ import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.endpoint.AbstractEndpoint; import org.springframework.integration.expression.ExpressionUtils; import org.springframework.integration.expression.ValueExpression; -import org.springframework.integration.support.DefaultMessageBuilderFactory; import org.springframework.integration.support.channel.ChannelResolverUtils; import org.springframework.integration.support.management.TrackableComponent; import org.springframework.integration.util.JavaUtils; @@ -873,7 +872,7 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint headers, this.argsMapper, getMessageBuilderFactory()); } - @Nullable + @Nullable // NOSONAR - complexitty private Map headers(Method method, Map headerExpressions) { Map headers = null; // We don't want to eagerly resolve the error channel here @@ -896,25 +895,23 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint headers.put(MessageHeaders.REPLY_CHANNEL, IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME); } - if (getMessageBuilderFactory() instanceof DefaultMessageBuilderFactory) { - Set headerNames = new HashSet<>(headerExpressions.keySet()); + Set headerNames = new HashSet<>(headerExpressions.keySet()); - if (this.globalMethodMetadata != null) { - headerNames.addAll(this.globalMethodMetadata.getHeaderExpressions().keySet()); - } - - List methodParameters = GatewayMethodInboundMessageMapper.getMethodParameterList(method); - - for (MethodParameter methodParameter : methodParameters) { - Header header = methodParameter.getParameterAnnotation(Header.class); - if (header != null) { - String headerName = GatewayMethodInboundMessageMapper.determineHeaderName(header, methodParameter); - headerNames.add(headerName); - } - } - - validateHeaders(headerNames); + if (this.globalMethodMetadata != null) { + headerNames.addAll(this.globalMethodMetadata.getHeaderExpressions().keySet()); } + + List methodParameters = GatewayMethodInboundMessageMapper.getMethodParameterList(method); + + for (MethodParameter methodParameter : methodParameters) { + Header header = methodParameter.getParameterAnnotation(Header.class); + if (header != null) { + String headerName = GatewayMethodInboundMessageMapper.determineHeaderName(header, methodParameter); + headerNames.add(headerName); + } + } + + validateHeaders(headerNames); return headers; } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/util/IntegrationReactiveUtils.java b/spring-integration-core/src/main/java/org/springframework/integration/util/IntegrationReactiveUtils.java index 73ece318bb..1b9bb6ff72 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/util/IntegrationReactiveUtils.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/util/IntegrationReactiveUtils.java @@ -17,7 +17,6 @@ package org.springframework.integration.util; import java.time.Duration; -import java.util.function.Function; import org.reactivestreams.Publisher; @@ -47,7 +46,7 @@ public final class IntegrationReactiveUtils { /** * The subscriber context entry for {@link Flux#delayElements} - * from the {@link Mono#repeatWhenEmpty(Function)}. + * from the {@link Mono#repeatWhenEmpty(java.util.function.Function)}. */ public static final String DELAY_WHEN_EMPTY_KEY = "DELAY_WHEN_EMPTY_KEY"; diff --git a/spring-integration-test/src/main/java/org/springframework/integration/test/context/MockIntegrationContext.java b/spring-integration-test/src/main/java/org/springframework/integration/test/context/MockIntegrationContext.java index da7522a83e..5b7776c95e 100644 --- a/spring-integration-test/src/main/java/org/springframework/integration/test/context/MockIntegrationContext.java +++ b/spring-integration-test/src/main/java/org/springframework/integration/test/context/MockIntegrationContext.java @@ -162,8 +162,9 @@ public class MockIntegrationContext implements BeanFactoryAware { substituteMessageHandlerFor(consumerEndpointId, mockMessageHandler, true); } - public void substituteMessageHandlerFor(String consumerEndpointId, MessageHandler mockMessageHandler, - boolean autoStartup) { + public void substituteMessageHandlerFor(String consumerEndpointId, // NOSONAR - complexity + MessageHandler mockMessageHandler, boolean autoStartup) { + Object endpoint = this.beanFactory.getBean(consumerEndpointId, IntegrationConsumer.class); if (autoStartup && endpoint instanceof Lifecycle) { ((Lifecycle) endpoint).stop();