[ 
https://issues.apache.org/jira/browse/KAFKA-9093?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

huxihx reassigned KAFKA-9093:
-----------------------------

    Assignee: huxihx

> NullPointerException in KafkaConsumer with group.instance.id
> ------------------------------------------------------------
>
>                 Key: KAFKA-9093
>                 URL: https://issues.apache.org/jira/browse/KAFKA-9093
>             Project: Kafka
>          Issue Type: Bug
>          Components: clients
>    Affects Versions: 2.3.0
>            Reporter: Rolef Heinrich
>            Assignee: huxihx
>            Priority: Minor
>             Fix For: 2.3.1
>
>
> When using *group.instance.id=myUniqId[0]*, the KafkaConsumer's constructor 
> throws a NullpointerException in close():
>  
> {code:java}
> Caused by: java.lang.NullPointerException
>  at 
> org.apache.kafka.clients.consumer.KafkaConsumer.close(KafkaConsumer.java:2204)
>  at 
> org.apache.kafka.clients.consumer.KafkaConsumer.<init>(KafkaConsumer.java:825)
>  at 
> org.apache.kafka.clients.consumer.KafkaConsumer.<init>(KafkaConsumer.java:664)
>  at 
> org.apache.kafka.clients.consumer.KafkaConsumer.<init>(KafkaConsumer.java:644)
> {code}
> {{It turns out that the exception is thrown because the *log* member is not 
> yet initialized (still null) in the constructor when the original exception 
> is handled. The original exception is thrown before *log* is initailized.}}
> {{The side effect of this error is, that close does does not cleanup 
> resources as clean is supposed to do.}}
> *{{The used consumer properties for reference:}}*
>  
> {code:java}
> key.deserializer=com.ibm.streamsx.kafka.serialization....
> request.timeout.ms=25000
> value.deserializer=com.ibm.streamsx.kafka.serialization....
> client.dns.lookup=use_all_dns_ips
> metadata.max.age.ms=2000
> enable.auto.commit=false
> group.instance.id=myUniqId[0]
> max.poll.interval.ms=300000
> group.id=consumer-0
> metric.reporters=com.ibm.streamsx.kafka.clients.consum...
> reconnect.backoff.max.ms=10000
> bootstrap.servers=localhost:9092
> max.poll.records=50
> session.timeout.ms=20000
> client.id=C-J37-ReceivedMessages[0]
> allow.auto.create.topics=false
> metrics.sample.window.ms=10000
> retry.backoff.ms=500
> reconnect.backoff.ms=250{code}
> *Expected behaviour:* throw exception indicating that something is wrong with 
> the chosen group.instance.id.
> The documentation does not tell anything about valid values for 
> group.instance.id.
> *Reproduce:*
>  
>  
> {code:java}
>  
> import java.util.Properties;
> import org.apache.kafka.clients.consumer.ConsumerConfig;
> import org.apache.kafka.clients.consumer.KafkaConsumer;
> public class Main {
>     public static void main(String[] args) {
>         Properties props = new Properties();
>         props.put (ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
>         props.put (ConsumerConfig.GROUP_ID_CONFIG, "group-Id1");
>         props.put (ConsumerConfig.GROUP_INSTANCE_ID_CONFIG, "myUniqId[0]");
>         props.put (ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, 
> "org.apache.kafka.common.serialization.StringDeserializer");
>         props.put (ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, 
> "org.apache.kafka.common.serialization.StringDeserializer");
>         KafkaConsumer c = new KafkaConsumer (props);
>     }
> }
> Exception in thread "main" java.lang.NullPointerException
>       at 
> org.apache.kafka.clients.consumer.KafkaConsumer.close(KafkaConsumer.java:2204)
>       at 
> org.apache.kafka.clients.consumer.KafkaConsumer.<init>(KafkaConsumer.java:825)
>       at 
> org.apache.kafka.clients.consumer.KafkaConsumer.<init>(KafkaConsumer.java:664)
>       at 
> org.apache.kafka.clients.consumer.KafkaConsumer.<init>(KafkaConsumer.java:644)
>       at Main.main(Main.java:15)
> {code}
>  



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

Reply via email to