From 9db48fc9d28154db9206aa9fd674cc160d75ac8d Mon Sep 17 00:00:00 2001 From: Giacomo Baso <12575901+gbaso@users.noreply.github.com> Date: Mon, 14 Apr 2025 17:37:30 +0200 Subject: [PATCH] GH-3813: add missing nullability annotations to KafkaOperations (#3837) Fixes: #3813 Issue link: https://github.com/spring-projects/spring-kafka/issues/3813 **Auto-cherry-pick to `3.3.x`** Signed-off-by: Giacomo Baso Co-authored-by: Giacomo Baso --- .../kafka/core/KafkaOperations.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/spring-kafka/src/main/java/org/springframework/kafka/core/KafkaOperations.java b/spring-kafka/src/main/java/org/springframework/kafka/core/KafkaOperations.java index 5b8759ce..388804ba 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/core/KafkaOperations.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/core/KafkaOperations.java @@ -55,6 +55,7 @@ import org.springframework.messaging.Message; * @author Marius Bogoevici * @author Gary Russell * @author Biju Kunjummen + * @author Giacomo Baso */ public interface KafkaOperations { @@ -68,7 +69,7 @@ public interface KafkaOperations { * @param data The data. * @return a Future for the {@link SendResult}. */ - CompletableFuture> sendDefault(V data); + CompletableFuture> sendDefault(@Nullable V data); /** * Send the data to the default topic with the provided key and no partition. @@ -76,7 +77,7 @@ public interface KafkaOperations { * @param data The data. * @return a Future for the {@link SendResult}. */ - CompletableFuture> sendDefault(K key, V data); + CompletableFuture> sendDefault(K key, @Nullable V data); /** * Send the data to the default topic with the provided key and partition. @@ -85,7 +86,7 @@ public interface KafkaOperations { * @param data the data. * @return a Future for the {@link SendResult}. */ - CompletableFuture> sendDefault(Integer partition, K key, V data); + CompletableFuture> sendDefault(Integer partition, K key, @Nullable V data); /** * Send the data to the default topic with the provided key and partition. @@ -96,7 +97,7 @@ public interface KafkaOperations { * @return a Future for the {@link SendResult}. * @since 1.3 */ - CompletableFuture> sendDefault(Integer partition, Long timestamp, K key, V data); + CompletableFuture> sendDefault(Integer partition, Long timestamp, K key, @Nullable V data); /** * Send the data to the provided topic with no key or partition. @@ -104,7 +105,7 @@ public interface KafkaOperations { * @param data The data. * @return a Future for the {@link SendResult}. */ - CompletableFuture> send(String topic, V data); + CompletableFuture> send(String topic, @Nullable V data); /** * Send the data to the provided topic with the provided key and no partition. @@ -113,7 +114,7 @@ public interface KafkaOperations { * @param data The data. * @return a Future for the {@link SendResult}. */ - CompletableFuture> send(String topic, K key, V data); + CompletableFuture> send(String topic, K key, @Nullable V data); /** * Send the data to the provided topic with the provided key and partition. @@ -123,7 +124,7 @@ public interface KafkaOperations { * @param data the data. * @return a Future for the {@link SendResult}. */ - CompletableFuture> send(String topic, Integer partition, K key, V data); + CompletableFuture> send(String topic, Integer partition, K key, @Nullable V data); /** * Send the data to the provided topic with the provided key and partition. @@ -135,7 +136,7 @@ public interface KafkaOperations { * @return a Future for the {@link SendResult}. * @since 1.3 */ - CompletableFuture> send(String topic, Integer partition, Long timestamp, K key, V data); + CompletableFuture> send(String topic, Integer partition, Long timestamp, K key, @Nullable V data); /** * Send the provided {@link ProducerRecord}.