You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by "Jun Rao (JIRA)" <ji...@apache.org> on 2013/05/08 18:31:18 UTC

[jira] [Commented] (KAFKA-897) NullPointerException in ConsoleConsumer

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

Jun Rao commented on KAFKA-897:
-------------------------------

Thanks for the patch. Actually, I think the wiki is inaccurate. The following is the comment on Message in the code. It seems that we only allow key to be null, but not value (since it's length is always >=0).

/**
 * A message. The format of an N byte message is the following:
 *
 * 1. 4 byte CRC32 of the message
 * 2. 1 byte "magic" identifier to allow format changes, value is 2 currently
 * 3. 1 byte "attributes" identifier to allow annotations on the message independent of the version (e.g. compression enabled, type of codec used)
 * 4. 4 byte key length, containing length K
 * 5. K byte key
 * 6. (N - K - 10) byte payload

                
> NullPointerException in ConsoleConsumer
> ---------------------------------------
>
>                 Key: KAFKA-897
>                 URL: https://issues.apache.org/jira/browse/KAFKA-897
>             Project: Kafka
>          Issue Type: Bug
>          Components: consumer
>    Affects Versions: 0.8
>            Reporter: Colin B.
>            Assignee: Neha Narkhede
>            Priority: Minor
>         Attachments: Kafka897-v1.patch
>
>
> The protocol document [1] mentions that keys and values in message sets can be null. However the ConsoleConsumer throws a NPE when a null is passed for the value.
> java.lang.NullPointerException
>         at kafka.utils.Utils$.readBytes(Utils.scala:141)
>         at kafka.consumer.ConsumerIterator.makeNext(ConsumerIterator.scala:106)
>         at kafka.consumer.ConsumerIterator.makeNext(ConsumerIterator.scala:33)
>         at kafka.utils.IteratorTemplate.maybeComputeNext(IteratorTemplate.scala:61)
>         at kafka.utils.IteratorTemplate.hasNext(IteratorTemplate.scala:53)
>         at scala.collection.Iterator$class.foreach(Iterator.scala:631)
>         at kafka.utils.IteratorTemplate.foreach(IteratorTemplate.scala:32)
>         at scala.collection.IterableLike$class.foreach(IterableLike.scala:79)
>         at kafka.consumer.KafkaStream.foreach(KafkaStream.scala:25)
>         at kafka.consumer.ConsoleConsumer$.main(ConsoleConsumer.scala:195)
>         at kafka.consumer.ConsoleConsumer.main(ConsoleConsumer.scala)
> [1] https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol#AGuideToTheKafkaProtocol-Messagesets

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira