GH-3648: Fix @Gateway.payloadExpression

Resolves https://github.com/spring-projects/spring-integration/issues/3648

When configuring a gateway proxy with XML, but specifying the payload expression
on the method `@Gateway` annotation, the expression was ignored, even though it
had been parsed.

`@Payload` worked.

With this change, if both `@Payload` and `@Gateway` are defined on a gateway method,
`@Gateway.payloadExpression` wins.

* Fix doc links.
This commit is contained in:
Gary Russell
2021-10-20 15:09:29 -04:00
committed by GitHub
parent 035581b421
commit e84bab6e0a
5 changed files with 61 additions and 13 deletions

View File

@@ -150,6 +150,26 @@ public class GatewayParserTests {
assertThat(result).isEqualTo("foo");
}
@Test
public void testRequestReplyNoArgsGw() {
PollableChannel requestChannel = (PollableChannel) context.getBean("requestChannel");
MessageChannel replyChannel = (MessageChannel) context.getBean("replyChannel");
this.startResponder(requestChannel, replyChannel);
TestService service = (TestService) context.getBean("requestReply");
String result = service.noArgWithGateway();
assertThat(result).isEqualTo("fromGwExpression");
}
@Test
public void testRequestReplyNoArgsBothAnn() {
PollableChannel requestChannel = (PollableChannel) context.getBean("requestChannel");
MessageChannel replyChannel = (MessageChannel) context.getBean("replyChannel");
this.startResponder(requestChannel, replyChannel);
TestService service = (TestService) context.getBean("requestReply");
String result = service.noArgWithGatewayAndPayload();
assertThat(result).isEqualTo("fromGwExpression");
}
@Test
public void testAsyncGateway() throws Exception {
PollableChannel requestChannel = (PollableChannel) context.getBean("requestChannel");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -71,6 +71,13 @@ public interface TestService {
throw new UnsupportedOperationException();
}
@Gateway(payloadExpression = "'fromGwExpression'", requestChannel = "requestChannel")
String noArgWithGateway();
@Payload("'fromPayloadAnnExpression'")
@Gateway(payloadExpression = "'fromGwExpression'", requestChannel = "requestChannel")
String noArgWithGatewayAndPayload();
class MyCompletableFuture extends CompletableFuture<String> {
}