Kevin created KAFKA-8217:
----------------------------
Summary: MockConsumer.poll executes pollTasks before checking
wakeup flag
Key: KAFKA-8217
URL: https://issues.apache.org/jira/browse/KAFKA-8217
Project: Kafka
Issue Type: Bug
Components: unit tests
Affects Versions: 2.0.1
Reporter: Kevin
The tasks scheduled in MockConsumer.schedulePollTask seem to be for simulating
interactions between the Consumer and the brokers, but MockConsumer.poll runs
scheduledPollTasks before it checks the wakeup flag. Given that the
KafkaConsumer.poll method checks the wakeup flag before doing any other logic,
it seems like the MockConsumer should rather check wakeup before running
scheduledPollTasks.
This makes it difficult to control exactly how many Consumer.poll invocations
occur in a unit test when using the wakeup() pattern described in
"Multithreaded Processing" in the KafkaConsumer docs, as gating each poll so
that it returns only when instructed in the test requires submitting a
scheduledPollTask that blocks until the test unblocks it. The trouble occurs
when trying to shut down the consumer, as the poll() task needs to be unblocked
in order to receive the WakeupException but
https://issues.apache.org/jira/browse/KAFKA-8216 means that Consumer.poll() can
be called many times in the race condition interval after poll has been
unblocked but before the test has called Consumer.wakeup().
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)