[INT-4449] Messaging Gateway: the @Gateway(payloadExpression = ) is not consulted when no method args Created: 11/Apr/18  Updated: 18/Apr/18  Resolved: 18/Apr/18

Status: Resolved
Project: Spring Integration
Component/s: Core
Affects Version/s: 4.3.15
Fix Version/s: 5.1 M1, 5.0.5, 4.3.16

Type: Bug Priority: Minor
Reporter: Artem Bilan Assignee: Artem Bilan
Resolution: Complete Votes: 0
Labels: PullRequest
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Reference URL: https://stackoverflow.com/questions/49783344/using-gateway-to-consume-spring-boot-application-from-spring-integration-applica
Pull Request URL: https://github.com/spring-projects/spring-integration/pull/2420

 Description   
@Gateway(payloadExpression = "'foo'")
String getData();

We end up with the exception like:

java.lang.IllegalStateException: receive is not supported, because no pollable reply channel has been configured

	at org.springframework.util.Assert.state(Assert.java:73)
	at org.springframework.integration.gateway.MessagingGatewaySupport.receive(MessagingGatewaySupport.java:447)
	at org.springframework.integration.gateway.GatewayProxyFactoryBean.invokeGatewayMethod(GatewayProxyFactoryBean.java:510)
	at org.springframework.integration.gateway.GatewayProxyFactoryBean.doInvoke(GatewayProxyFactoryBean.java:469)
	at org.springframework.integration.gateway.GatewayProxyFactoryBean.invoke(GatewayProxyFactoryBean.java:460)

Just because the payloadExpression is populated to the GatewayMethodInboundMessageMapper, but not into the GatewayMethodMetadata to be available when we consult for non-args method:

if (!hasPayloadExpression && this.methodMetadataMap != null) {
	// check for the method metadata next
	GatewayMethodMetadata metadata = this.methodMetadataMap.get(method.getName());
	hasPayloadExpression = (metadata != null) && StringUtils.hasText(metadata.getPayloadExpression());
}

Generated at Tue Dec 10 11:15:47 UTC 2019 using Jira 7.13.8#713008-sha1:1606a5c1e7006e1ab135aac81f7a9566b2dbc3a6.