You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Gérald Quintana (Jira)" <ji...@apache.org> on 2021/05/28 15:37:00 UTC

[jira] [Created] (KAFKA-12861) MockProducer raises NPE when no Serializer

Gérald Quintana created KAFKA-12861:
---------------------------------------

             Summary: MockProducer raises NPE when no Serializer
                 Key: KAFKA-12861
                 URL: https://issues.apache.org/jira/browse/KAFKA-12861
             Project: Kafka
          Issue Type: Bug
          Components: clients
    Affects Versions: 2.7.1, 2.8.0, 2.7.0
            Reporter: Gérald Quintana


Since KAFKA-10503, the MockProducer may raise NullPointerException when key/value serializers are not set:
*15:58:16*  java.lang.NullPointerException: null*15:58:16*  	at org.apache.kafka.clients.producer.MockProducer.send(MockProducer.java:307)
This occurs when using MockProducer default constructor:
{code:java}
public MockProducer() {
 this(Cluster.empty(), false, null, null, null);
}{code}
The problem didn't occur on Kafka Client 2.6.

I understand this constructor is only for metadata as described in JavaDoc. However defaulting to a Noop serializer (MockSerializer) would be a better default. Removing the default constructor to force declaring a serialiszer could also be a solution.



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