Skip to content

Commit 86f94c5

Browse files
garyrussellartembilan
authored andcommitted
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** # Conflicts: # spring-kafka/src/main/java/org/springframework/kafka/listener/adapter/DelegatingInvocableHandler.java
1 parent f314ee4 commit 86f94c5

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-2021 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.
@@ -217,8 +217,8 @@ protected InvocableHandlerMethod getHandlerForPayload(Class<? extends Object> pa
217217
if (handler == null) {
218218
throw new KafkaException("No method found for " + payloadClass);
219219
}
220-
this.cachedHandlers.putIfAbsent(payloadClass, handler); //NOSONAR
221220
setupReplyTo(handler);
221+
this.cachedHandlers.putIfAbsent(payloadClass, handler); //NOSONAR
222222
}
223223
return handler;
224224
}

0 commit comments

Comments
 (0)