IgnacioAcunaF commented on a change in pull request #10858:
URL: https://github.com/apache/kafka/pull/10858#discussion_r651770604



##########
File path: core/src/main/scala/kafka/admin/ConsumerGroupCommand.scala
##########
@@ -580,7 +581,8 @@ object ConsumerGroupCommand extends Logging {
             groupId,
             Option(consumerGroup.coordinator),
             unassignedPartitions.keySet.toSeq,
-            unassignedPartitions.map { case (tp, offset) => tp -> 
Some(offset.offset) },
+            // Because there could be cases where the last commited offset is 
a negative integer (which translates to null [KAFKA-9507 for reference]), the 
following map function could lead to a NullPointerException. Two possible types 
are possible: OffsetsAndMetadata or null (which gets translated to None to 
avoid further exceptions)
+            unassignedPartitions.map { case (tp, offset) => tp -> ( 
if(offset.isInstanceOf[OffsetAndMetadata]) Some(offset.offset) else None ) },

Review comment:
       Absolutely right, same helper function works both cases and keeps the 
code cleaner and consistent. Going to change that.




-- 
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to