[ 
https://issues.apache.org/jira/browse/KAFKA-9679?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17059634#comment-17059634
 ] 

Sujay Hegde commented on KAFKA-9679:
------------------------------------

[~bchen225242],

 

Do we still have this issue?

I went through MockConsumer and came across:

public synchronized void addRecord(ConsumerRecord<K, V> record) {
 ensureNotClosed();
 TopicPartition tp = new TopicPartition(record.topic(), record.partition());
 Set<TopicPartition> currentAssigned = this.subscriptions.assignedPartitions();
 if (!currentAssigned.contains(tp))
 throw new IllegalStateException("Cannot add records for a partition that is 
not assigned to the consumer");
 List<ConsumerRecord<K, V>> recs = this.records.computeIfAbsent(tp, k -> new 
ArrayList<>());
 recs.add(record);
}

Is this what you were referring to?
I feel this is a bit different from whats mentioned in description(I may be 
wrong).
In above we dont add records to a partition if we cannot find a consumer to 
which the partition is assigned to.

> Mock consumer should behave consistent with actual consumer
> -----------------------------------------------------------
>
>                 Key: KAFKA-9679
>                 URL: https://issues.apache.org/jira/browse/KAFKA-9679
>             Project: Kafka
>          Issue Type: Test
>          Components: consumer, streams
>            Reporter: Boyang Chen
>            Assignee: Sujay Hegde
>            Priority: Major
>              Labels: help-wanted, newbie, newbie++
>
> Right now in MockConsumer we shall return illegal state exception when the 
> buffered records are not able to find corresponding assigned partitions. This 
> is not the case for KafkaConsumer where we shall just not return those data 
> during `poll()` call. This inconsistent behavior should be fixed.
> Note that if we are going to take this fix, the full unit tests need to be 
> executed to make sure no regression is introduced, as some tests are 
> potentially depending on the current MockConsumer behavior.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to