Skip to content

Commit 948f5a3

Browse files
committed
Remove IntegrationPatternType.gateway
The `GatewayProxyFactoryBean` really produces an Inbound Gateway for downstream flow and its proxy becomes a start of the flow * Determine a return type of the gateway method to indicate that `void` one leads to the `IntegrationPatternType.inbound_channel_adapter` instead of regular `IntegrationPatternType.inbound_gateway`
1 parent 09f1110 commit 948f5a3

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

spring-integration-core/src/main/java/org/springframework/integration/IntegrationPatternType.java

-3
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ public enum IntegrationPatternType {
5454

5555
inbound_gateway(IntegrationPatternCategory.messaging_endpoint),
5656

57-
gateway(IntegrationPatternCategory.messaging_endpoint),
58-
5957
splitter(IntegrationPatternCategory.message_routing),
6058

6159
transformer(IntegrationPatternCategory.message_transformation),
@@ -121,7 +119,6 @@ public enum IntegrationPatternCategory {
121119
inbound_channel_adapter,
122120
outbound_gateway,
123121
inbound_gateway,
124-
gateway,
125122
bridge),
126123

127124
message_routing(

spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayProxyFactoryBean.java

+13-1
Original file line numberDiff line numberDiff line change
@@ -939,13 +939,17 @@ private static final class MethodInvocationGateway extends MessagingGatewaySuppo
939939

940940
private boolean isMonoReturn;
941941

942+
private boolean isVoidReturn;
943+
942944
MethodInvocationGateway(GatewayMethodInboundMessageMapper messageMapper) {
943945
setRequestMapper(messageMapper);
944946
}
945947

946948
@Override
947949
public IntegrationPatternType getIntegrationPatternType() {
948-
return IntegrationPatternType.gateway;
950+
return this.isVoidReturn
951+
? IntegrationPatternType.inbound_channel_adapter
952+
: IntegrationPatternType.inbound_gateway;
949953
}
950954

951955
@Nullable
@@ -973,13 +977,21 @@ void setupReturnType(Class<?> serviceInterface, Method method) {
973977
this.isMonoReturn = Mono.class.isAssignableFrom(this.returnType);
974978
this.expectMessage = hasReturnParameterizedWithMessage(resolvableType);
975979
}
980+
this.isVoidReturn = isVoidReturnType(resolvableType);
976981
}
977982

978983
private boolean hasReturnParameterizedWithMessage(ResolvableType resolvableType) {
979984
return (Future.class.isAssignableFrom(this.returnType) || Mono.class.isAssignableFrom(this.returnType))
980985
&& Message.class.isAssignableFrom(resolvableType.getGeneric(0).resolve(Object.class));
981986
}
982987

988+
private boolean isVoidReturnType(ResolvableType resolvableType) {
989+
Class<?> returnTypeToCheck = this.returnType;
990+
if (Future.class.isAssignableFrom(this.returnType) || Mono.class.isAssignableFrom(this.returnType)) {
991+
returnTypeToCheck = resolvableType.getGeneric(0).resolve(Object.class);
992+
}
993+
return Void.class.isAssignableFrom(returnTypeToCheck);
994+
}
983995
}
984996

985997
private final class Invoker implements Supplier<Object> {

0 commit comments

Comments
 (0)