kafka-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Xing Huang (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (KAFKA-3905) remove null from subscribed topics in KafkaConsumer#subscribe
Date Tue, 28 Jun 2016 05:22:57 GMT

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

Xing Huang edited comment on KAFKA-3905 at 6/28/16 5:22 AM:
------------------------------------------------------------

I think IllegalArgumentException with an error message will be enough. And, empty string should
cause an exception too. 


was (Author: peoplebike):
I think IllegalArgumentException with an error message will be enough. And, empty string cause
an exception too. 

> remove null from subscribed topics  in KafkaConsumer#subscribe
> --------------------------------------------------------------
>
>                 Key: KAFKA-3905
>                 URL: https://issues.apache.org/jira/browse/KAFKA-3905
>             Project: Kafka
>          Issue Type: Wish
>          Components: clients
>    Affects Versions: 0.10.0.0
>            Reporter: Xing Huang
>            Assignee: Rekha Joshi
>            Priority: Minor
>
> Currently, KafkaConsumer's subscribe methods accept Collection<String> as topics
to be subscribed, but a Collection may have null as its element. For example
> {code}
>             String topic = null;
>             Collection<String> topics = Arrays.asList(topic);
>             consumer.subscribe(topics)
> {code}
> When this happens, consumer will throw a puzzling NullPointerException:
> {code}
> 	at org.apache.kafka.common.utils.Utils.utf8Length(Utils.java:245)
> 	at org.apache.kafka.common.protocol.types.Type$6.sizeOf(Type.java:248)
> 	at org.apache.kafka.common.protocol.types.ArrayOf.sizeOf(ArrayOf.java:85)
> 	at org.apache.kafka.common.protocol.types.Schema.sizeOf(Schema.java:89)
> 	at org.apache.kafka.common.protocol.types.Struct.sizeOf(Struct.java:244)
> 	at org.apache.kafka.common.requests.RequestSend.serialize(RequestSend.java:35)
> 	at org.apache.kafka.common.requests.RequestSend.<init>(RequestSend.java:29)
> 	at org.apache.kafka.clients.NetworkClient$DefaultMetadataUpdater.request(NetworkClient.java:616)
> 	at org.apache.kafka.clients.NetworkClient$DefaultMetadataUpdater.maybeUpdate(NetworkClient.java:639)
> 	at org.apache.kafka.clients.NetworkClient$DefaultMetadataUpdater.maybeUpdate(NetworkClient.java:552)
> 	at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:258)
> 	at org.apache.kafka.clients.consumer.internals.ConsumerNetworkClient.clientPoll(ConsumerNetworkClient.java:360)
> 	at org.apache.kafka.clients.consumer.internals.ConsumerNetworkClient.poll(ConsumerNetworkClient.java:224)
> 	at org.apache.kafka.clients.consumer.internals.ConsumerNetworkClient.poll(ConsumerNetworkClient.java:192)
> 	at org.apache.kafka.clients.consumer.internals.ConsumerNetworkClient.poll(ConsumerNetworkClient.java:163)
> 	at org.apache.kafka.clients.consumer.internals.AbstractCoordinator.ensureCoordinatorReady(AbstractCoordinator.java:179)
> 	at org.apache.kafka.clients.consumer.KafkaConsumer.pollOnce(KafkaConsumer.java:970)
> 	at org.apache.kafka.clients.consumer.KafkaConsumer.poll(KafkaConsumer.java:934)
> {code}
> Maybe it's better to remove null when doing subscription.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message