Skip to content

Commit 4d2e00d

Browse files
artembilangaryrussell
authored andcommitted
Fix LambdaMessageProcessor for Map payload
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**
1 parent abfda64 commit 4d2e00d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

spring-integration-core/src/main/java/org/springframework/integration/handler/LambdaMessageProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public Object processMessage(Message<?> message) {
100100
args[i] = message;
101101
}
102102
else if (Map.class.isAssignableFrom(parameterType)) {
103-
if (message.getPayload() instanceof Map) {
103+
if (message.getPayload() instanceof Map && this.parameterTypes.length == 1) {
104104
args[i] = message.getPayload();
105105
}
106106
else {

spring-integration-webflux/src/test/java/org/springframework/integration/webflux/dsl/WebFluxDslTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,10 @@ public IntegrationFlow httpReactiveInboundChannelAdapterFlow() {
299299
public IntegrationFlow sseFlow() {
300300
return IntegrationFlows
301301
.from(WebFlux.inboundGateway("/sse")
302-
.requestMapping(m -> m.produces(MediaType.TEXT_EVENT_STREAM_VALUE)))
303-
.handle((p, h) -> Flux.just("foo", "bar", "baz"))
302+
.requestMapping(m -> m.produces(MediaType.TEXT_EVENT_STREAM_VALUE))
303+
.mappedResponseHeaders("*"))
304+
.enrichHeaders(Collections.singletonMap("aHeader", new String[] { "foo", "bar", "baz" }))
305+
.handle((p, h) -> Flux.fromArray((String[]) h.get("aHeader")))
304306
.get();
305307
}
306308

0 commit comments

Comments
 (0)