Skip to content

Commit 0af670b

Browse files
committed
spring-projectsGH-3697: Optimize a MessagingMessageListenerAdapter returning null from the DelegatingInvocableHandler.invoke()
1 parent 5f7b151 commit 0af670b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

+7-2
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ public boolean isAsyncReplies() {
167167
* @throws Exception raised if no suitable argument resolver can be found,
168168
* or the method raised an exception.
169169
*/
170+
@Nullable
170171
public Object invoke(Message<?> message, Object... providedArgs) throws Exception { //NOSONAR
171172
Class<?> payloadClass = message.getPayload().getClass();
172173
InvocableHandlerMethod handler = getHandlerForPayload(payloadClass);
@@ -186,8 +187,12 @@ public Object invoke(Message<?> message, Object... providedArgs) throws Exceptio
186187
else {
187188
result = handler.invoke(message, providedArgs);
188189
}
189-
Expression replyTo = this.handlerSendTo.get(handler);
190-
return new InvocationResult(result, replyTo, this.handlerReturnsMessage.get(handler));
190+
if (result != null) {
191+
Expression replyTo = this.handlerSendTo.get(handler);
192+
return new InvocationResult(result, replyTo, this.handlerReturnsMessage.get(handler));
193+
} else {
194+
return null;
195+
}
191196
}
192197

193198
/**

0 commit comments

Comments
 (0)