You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by "Olaf (Jira)" <ji...@apache.org> on 2021/02/05 12:45:00 UTC
[jira] [Resolved] (KAFKA-12296) MockProducer behaves contrary to
documentation of Callback
[ https://issues.apache.org/jira/browse/KAFKA-12296?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Olaf resolved KAFKA-12296.
--------------------------
Resolution: Duplicate
sorry - wrong user
> MockProducer behaves contrary to documentation of Callback
> ----------------------------------------------------------
>
> Key: KAFKA-12296
> URL: https://issues.apache.org/jira/browse/KAFKA-12296
> Project: Kafka
> Issue Type: Bug
> Components: producer , unit tests
> Affects Versions: 2.7.0
> Reporter: Olaf
> Priority: Major
>
> In Unit tests, a MockProducer is used to imitate a real producer.
> Using the errorNext(RuntimeException e) method, it is possible to indicate failures.
> BUT: the asynchronous send method with a callback has a clear documentation of that callback interface, stating that Metadata will always be set, and never null.
> {{The metadata for the record that was sent (i.e. the partition and offset). An empty metadata with -1 value for all fields except for topicPartition will be returned if an error occurred.}}
>
> The bug is, that in MockProducer's Completion implementation the following happens:
> {{if (e == null)}}
> {{ callback.onCompletion(metadata, null);}}
> {{else}}
> {{ callback.onCompletion(null, e);}}
>
> Behaving against the own documentation leads to very subtle bugs: tests that implement the error condition checking metadata != null will be fine, but in real life fail horribly.
>
> A MockProducer should at all times behave exactly like the real thing and adhere to the documentation of the Callback!
--
This message was sent by Atlassian Jira
(v8.3.4#803005)