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

    • Bug
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • 2.0.1
    • 2.2.0
    • clients
    • 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

              srdo Stig Rohde Døssing
              srdo Stig Rohde Døssing
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: