You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by "Raghu Angadi (JIRA)" <ji...@apache.org> on 2018/01/24 20:51:00 UTC

[jira] [Commented] (BEAM-2704) KafkaIO: NPE without key serializer set

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

Raghu Angadi commented on BEAM-2704:
------------------------------------

Resolving this as  BEAM-2257 is fixed (it still needs to be marked resolved).

> KafkaIO: NPE without key serializer set
> ---------------------------------------
>
>                 Key: BEAM-2704
>                 URL: https://issues.apache.org/jira/browse/BEAM-2704
>             Project: Beam
>          Issue Type: Bug
>          Components: sdk-java-extensions
>            Reporter: Chris Pettitt
>            Assignee: Raghu Angadi
>            Priority: Major
>
> The KafkaIO javadoc implies that you do not need to set a Serializer if you only want to emit values:
> {code}
>  * <p>Often you might want to write just values without any keys to Kafka. Use {@code values()} to
>  * write records with default empty(null) key:
>  *
>  * <pre>{@code
>  *  PCollection<String> strings = ...;
>  *  strings.apply(KafkaIO.<Void, String>write()
>  *      .withBootstrapServers("broker_1:9092,broker_2:9092")
>  *      .withTopic("results")
>  *      .withValueSerializer(new StringSerializer()) // just need serializer for value
>  *      .values()
>  *    );
>  * }</pre>
> {code}
> However, if you don't set the key serializer then Kafka blows up when trying to instantiate the key serializer (in Kafka 0.10.1, at least). It would be more convenient if KafkaIO worked as documented and assigned a null serializer if values() is used.  
> Relevant stack trace:
> {code}
> Caused by: java.lang.NullPointerException
> 	at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:230)
> 	at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:163)
> 	at org.apache.beam.sdk.io.kafka.KafkaIO$KafkaWriter.setup(KafkaIO.java:1582)
> 	at org.apache.beam.sdk.io.kafka.KafkaIO$KafkaWriter$DoFnInvoker.invokeSetup(Unknown Source)
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)