From b1ebc457fd3f46bc1885818f5363694822eeb1e5 Mon Sep 17 00:00:00 2001 From: Soby Chacko Date: Mon, 9 Jan 2023 20:02:45 -0500 Subject: [PATCH] StreamBridge and KafkaNull When sending KafkaNull over StreamBridge, we need to repackage the potential null result back into KafkaNull. --- .../cloud/stream/function/StreamBridge.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/function/StreamBridge.java b/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/function/StreamBridge.java index a2551421d..ee6363b42 100644 --- a/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/function/StreamBridge.java +++ b/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/function/StreamBridge.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2021 the original author or authors. + * Copyright 2020-2023 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. @@ -172,6 +172,11 @@ public final class StreamBridge implements StreamOperations, SmartInitializingSi resultMessage = (Message) functionToInvoke.apply(messageToSend); } + if (resultMessage == null + && ((Message) messageToSend).getPayload().getClass().getName().equals("org.springframework.kafka.support.KafkaNull")) { + resultMessage = messageToSend; + } + resultMessage = (Message) this.functionInvocationHelper.postProcessResult(resultMessage, null); return messageChannel.send(resultMessage);