Skip to content

Commit 25a6924

Browse files
committed
DelegatingInvocableHandler.invoke() returning null
Signed-off-by: ivamly <[email protected]>
1 parent 1595907 commit 25a6924

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

spring-kafka/src/main/java/org/springframework/kafka/listener/adapter/DelegatingInvocableHandler.java

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2024 the original author or authors.
2+
* Copyright 2016-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -55,6 +55,7 @@
5555
*
5656
* @author Gary Russell
5757
* @author Wang Zhiyang
58+
* @author Ivan Malutin
5859
*
5960
*/
6061
public class DelegatingInvocableHandler {
@@ -167,6 +168,7 @@ public boolean isAsyncReplies() {
167168
* @throws Exception raised if no suitable argument resolver can be found,
168169
* or the method raised an exception.
169170
*/
171+
@Nullable
170172
public Object invoke(Message<?> message, Object... providedArgs) throws Exception { //NOSONAR
171173
Class<?> payloadClass = message.getPayload().getClass();
172174
InvocableHandlerMethod handler = getHandlerForPayload(payloadClass);
@@ -186,8 +188,13 @@ public Object invoke(Message<?> message, Object... providedArgs) throws Exceptio
186188
else {
187189
result = handler.invoke(message, providedArgs);
188190
}
189-
Expression replyTo = this.handlerSendTo.get(handler);
190-
return new InvocationResult(result, replyTo, this.handlerReturnsMessage.get(handler));
191+
if (result != null) {
192+
Expression replyTo = this.handlerSendTo.get(handler);
193+
return new InvocationResult(result, replyTo, this.handlerReturnsMessage.get(handler));
194+
}
195+
else {
196+
return null;
197+
}
191198
}
192199

193200
/**

0 commit comments

Comments
 (0)