Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-7616

MockConsumer can return ConsumerRecords objects with a non-empty map but no records

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 2.0.1
    • Fix Version/s: 2.2.0
    • Component/s: clients
    • Labels:
      None

      Description

      The ConsumerRecords returned from MockConsumer.poll can return false for isEmpty while not containing any records. This behavior is because MockConsumer.poll eagerly adds entries to the returned Map<TopicPartition, List<ConsumerRecord>>, based on which partitions have been added. If no records are returned for a partition, e.g. because the position was too far ahead, the entry for that partition will still be there.

       

      The MockConsumer should lazily add entries to the map as they are needed, since it is more in line with how the real consumer behaves.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Srdo Stig Rohde Døssing
                Reporter:
                Srdo Stig Rohde Døssing
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: