Skip to content

Commit

Permalink
Fix LambdaMessageProcessor for Map payload
Browse files Browse the repository at this point in the history
JIRA: https://jira.spring.io/browse/INT-4478

When we use a `GenericHandler` and an incoming payload is a `Map`, we
copy it into both arguments into the `Object` for the payload
and `Map` for the headers.
This way we lose headers in the target lambda

* Check a size of arguments on the target lambda and don't set a
payload into the `Map` argument if we have more than 1 arguments

**Cherry-pick to 5.0.x**
  • Loading branch information
artembilan authored and garyrussell committed May 31, 2018
1 parent af89733 commit 9a88140
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public Object processMessage(Message<?> message) {
args[i] = message;
}
else if (Map.class.isAssignableFrom(parameterType)) {
if (message.getPayload() instanceof Map) {
if (message.getPayload() instanceof Map && this.parameterTypes.length == 1) {
args[i] = message.getPayload();
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,10 @@ public IntegrationFlow httpReactiveInboundChannelAdapterFlow() {
public IntegrationFlow sseFlow() {
return IntegrationFlows
.from(WebFlux.inboundGateway("/sse")
.requestMapping(m -> m.produces(MediaType.TEXT_EVENT_STREAM_VALUE)))
.handle((p, h) -> Flux.just("foo", "bar", "baz"))
.requestMapping(m -> m.produces(MediaType.TEXT_EVENT_STREAM_VALUE))
.mappedResponseHeaders("*"))
.enrichHeaders(Collections.singletonMap("aHeader", new String[] { "foo", "bar", "baz" }))
.handle((p, h) -> Flux.fromArray((String[]) h.get("aHeader")))
.get();
}

Expand Down

0 comments on commit 9a88140

Please sign in to comment.