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);