From 25a6924abc02fd175dd19e24e691b2f56fab3b5d Mon Sep 17 00:00:00 2001 From: ivamly Date: Sat, 18 Jan 2025 22:16:56 +0300 Subject: [PATCH] DelegatingInvocableHandler.invoke() returning null Signed-off-by: ivamly --- .../adapter/DelegatingInvocableHandler.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/spring-kafka/src/main/java/org/springframework/kafka/listener/adapter/DelegatingInvocableHandler.java b/spring-kafka/src/main/java/org/springframework/kafka/listener/adapter/DelegatingInvocableHandler.java index 3770dc6eed..cb225e2b27 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/listener/adapter/DelegatingInvocableHandler.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/listener/adapter/DelegatingInvocableHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2024 the original author or authors. + * Copyright 2016-2025 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. @@ -55,6 +55,7 @@ * * @author Gary Russell * @author Wang Zhiyang + * @author Ivan Malutin * */ public class DelegatingInvocableHandler { @@ -167,6 +168,7 @@ public boolean isAsyncReplies() { * @throws Exception raised if no suitable argument resolver can be found, * or the method raised an exception. */ + @Nullable public Object invoke(Message message, Object... providedArgs) throws Exception { //NOSONAR Class payloadClass = message.getPayload().getClass(); InvocableHandlerMethod handler = getHandlerForPayload(payloadClass); @@ -186,8 +188,13 @@ public Object invoke(Message message, Object... providedArgs) throws Exceptio else { result = handler.invoke(message, providedArgs); } - Expression replyTo = this.handlerSendTo.get(handler); - return new InvocationResult(result, replyTo, this.handlerReturnsMessage.get(handler)); + if (result != null) { + Expression replyTo = this.handlerSendTo.get(handler); + return new InvocationResult(result, replyTo, this.handlerReturnsMessage.get(handler)); + } + else { + return null; + } } /**