aashish-confluent commented on code in PR #24015:
URL: https://github.com/apache/kafka/pull/24015#discussion_r4467118132


##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableImpl.java:
##########
@@ -1505,7 +1505,15 @@ public Optional<Set<Integer>> partitions(final String 
topic,
                                                  final Headers headers,
                                                  final int numPartitions) {
             final Integer partition = value.primaryPartition();
-            return partition == null ? Optional.empty() : 
Optional.of(Set.of(partition));
+            if (partition == null) {
+                return Optional.empty();
+            }
+            if (partition < 0 || partition >= numPartitions) {

Review Comment:
   You arere right, thanks
   The partition comes from `taskId().partition()`, so it can't be -1 in 
punctuation. The guard is only for a corrupted subscription record, like in the 
new test. 



##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableImpl.java:
##########
@@ -1505,7 +1505,15 @@ public Optional<Set<Integer>> partitions(final String 
topic,
                                                  final Headers headers,
                                                  final int numPartitions) {
             final Integer partition = value.primaryPartition();
-            return partition == null ? Optional.empty() : 
Optional.of(Set.of(partition));
+            if (partition == null) {
+                return Optional.empty();
+            }
+            if (partition < 0 || partition >= numPartitions) {

Review Comment:
   You are right, thanks
   The partition comes from `taskId().partition()`, so it can't be -1 in 
punctuation. The guard is only for a corrupted subscription record, like in the 
new test. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to