From e422fb6d9d9f4ac7e495e66b166309747b2fca32 Mon Sep 17 00:00:00 2001 From: Tom Bentley Date: Thu, 5 Mar 2020 18:08:54 +0000 Subject: [PATCH] KAFKA-9663: Doc some null returns in KafkaStreams Documents the possibility of null return value in KafkaStreams.getMetadataForKey(), and KafkaStreams.queryMetadataForKey(). This fixes KAFKA-9663. --- .../java/org/apache/kafka/streams/KafkaStreams.java | 11 +++++++---- .../processor/internals/StreamsMetadataState.java | 9 +++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java b/streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java index a48dd6a9646ae..45d6acb729175 100644 --- a/streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java +++ b/streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java @@ -1083,7 +1083,8 @@ public Collection allMetadataForStore(final String storeName) { * @param keySerializer serializer for the key * @param key type * @return {@link StreamsMetadata} for the {@code KafkaStreams} instance with the provided {@code storeName} and - * {@code key} of this application or {@link StreamsMetadata#NOT_AVAILABLE} if Kafka Streams is (re-)initializing + * {@code key} of this application or {@link StreamsMetadata#NOT_AVAILABLE} if Kafka Streams is (re-)initializing, + * or {@code null} if no matching metadata could be found. * @deprecated Since 2.5. Use {@link #queryMetadataForKey(String, Object, Serializer)} instead. */ @Deprecated @@ -1116,7 +1117,8 @@ public StreamsMetadata metadataForKey(final String storeName, * @param partitioner the partitioner to be use to locate the host for the key * @param key type * @return {@link StreamsMetadata} for the {@code KafkaStreams} instance with the provided {@code storeName} and - * {@code key} of this application or {@link StreamsMetadata#NOT_AVAILABLE} if Kafka Streams is (re-)initializing + * {@code key} of this application or {@link StreamsMetadata#NOT_AVAILABLE} if Kafka Streams is (re-)initializing, + * or {@code null} if no matching metadata could be found. * @deprecated Since 2.5. Use {@link #queryMetadataForKey(String, Object, StreamPartitioner)} instead. */ @Deprecated @@ -1134,7 +1136,8 @@ public StreamsMetadata metadataForKey(final String storeName, * @param key the key to find metadata for * @param keySerializer serializer for the key * @param key type - * Returns {@link KeyQueryMetadata} containing all metadata about hosting the given key for the given store. + * Returns {@link KeyQueryMetadata} containing all metadata about hosting the given key for the given store, + * or {@code null} if no matching metadata could be found. */ public KeyQueryMetadata queryMetadataForKey(final String storeName, final K key, @@ -1151,7 +1154,7 @@ public KeyQueryMetadata queryMetadataForKey(final String storeName, * @param partitioner the partitioner to be use to locate the host for the key * @param key type * Returns {@link KeyQueryMetadata} containing all metadata about hosting the given key for the given store, using the - * the supplied partitioner + * the supplied partitioner, or {@code null} if no matching metadata could be found. */ public KeyQueryMetadata queryMetadataForKey(final String storeName, final K key, diff --git a/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java b/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java index c74605923159a..d9ad2a4ce8837 100644 --- a/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java +++ b/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java @@ -137,7 +137,7 @@ public synchronized Collection getAllMetadataForStore(final Str * @param keySerializer Serializer for the key * @param key type * @return The {@link StreamsMetadata} for the storeName and key or {@link StreamsMetadata#NOT_AVAILABLE} - * if streams is (re-)initializing + * if streams is (re-)initializing, or {@code null} if no matching metadata could be found. * @deprecated Use {@link #getKeyQueryMetadataForKey(String, Object, Serializer)} instead. */ @Deprecated @@ -185,7 +185,8 @@ public synchronized StreamsMetadata getMetadataWithKey(final String storeNam * @param keySerializer Serializer for the key * @param key type * @return The {@link KeyQueryMetadata} for the storeName and key or {@link KeyQueryMetadata#NOT_AVAILABLE} - * if streams is (re-)initializing or null if the corresponding topic cannot be found + * if streams is (re-)initializing or {@code null} if the corresponding topic cannot be found, + * or null if no matching metadata could be found. */ public synchronized KeyQueryMetadata getKeyQueryMetadataForKey(final String storeName, final K key, @@ -207,7 +208,7 @@ public synchronized KeyQueryMetadata getKeyQueryMetadataForKey(final String * @param partitioner partitioner to use to find correct partition for key * @param key type * @return The {@link KeyQueryMetadata} for the storeName and key or {@link KeyQueryMetadata#NOT_AVAILABLE} - * if streams is (re-)initializing + * if streams is (re-)initializing, or {@code null} if no matching metadata could be found. */ public synchronized KeyQueryMetadata getKeyQueryMetadataForKey(final String storeName, final K key, @@ -247,7 +248,7 @@ public synchronized KeyQueryMetadata getKeyQueryMetadataForKey(final String * @param partitioner partitioner to use to find correct partition for key * @param key type * @return The {@link StreamsMetadata} for the storeName and key or {@link StreamsMetadata#NOT_AVAILABLE} - * if streams is (re-)initializing + * if streams is (re-)initializing, or {@code null} if no matching metadata could be found. * @deprecated Use {@link #getKeyQueryMetadataForKey(String, Object, StreamPartitioner)} instead. */ @Deprecated