Skip to content

Commit 2a55f3f

Browse files
authored
GH-2723: Fix NPE in DelegatingInvocableHandler
Resolves #2723 Previously, it was possible for `handlerReturnsMessage` to return `null` when a `cachedHandlers` was present, causing an NPE when unboxing the `Boolean` value. Ensure that the `handlerReturnsMessage` map is populated before adding the handler to `cachedHandlers`. **cherry-pick to 2.9.x**
1 parent aa92c93 commit 2a55f3f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2022 the original author or authors.
2+
* Copyright 2016-2023 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.
@@ -182,8 +182,8 @@ protected InvocableHandlerMethod getHandlerForPayload(Class<? extends Object> pa
182182
if (handler == null) {
183183
throw new KafkaException("No method found for " + payloadClass);
184184
}
185-
this.cachedHandlers.putIfAbsent(payloadClass, handler); //NOSONAR
186185
setupReplyTo(handler);
186+
this.cachedHandlers.putIfAbsent(payloadClass, handler); //NOSONAR
187187
}
188188
return handler;
189189
}

0 commit comments

Comments
 (0)