How does Kafka treat negative number in partition in ProducerRecord in Kafka Client 0.10?

Multi tool use
How does Kafka treat negative number in partition in ProducerRecord in Kafka Client 0.10?
In Kafka Client 1.1.0 a check is placed to not allow negative as partition
in ProducerRecord
.
partition
ProducerRecord
https://github.com/apache/kafka/blob/1.1/clients/src/main/java/org/apache/kafka/clients/producer/ProducerRecord.java#L73
But I don't see any such check in ProducerRecord
in kafka client 0.10.0.
ProducerRecord
https://github.com/apache/kafka/blob/0.10.0/clients/src/main/java/org/apache/kafka/clients/producer/ProducerRecord.java#L62
Can someone let me know how does Kafka handle the negative number in partition
in ProducerRecord
in 0.10? Will the partition be converted to positive number ? If yes can some one point me to the code / logic of the conversion?
partition
ProducerRecord
1 Answer
1
With the 0.10.0 Kafka Producer, a negative number for the partition is also rejected.
The check was not done in ProducerRecord
like in the recent releases but instead in KafkaProducer.partition()
and you would get the following stack trace:
ProducerRecord
KafkaProducer.partition()
Exception in thread "main" java.lang.IllegalArgumentException: Invalid partition given with record: -1 is not in the range [0...0].
at org.apache.kafka.clients.producer.KafkaProducer.partition(KafkaProducer.java:717)
at org.apache.kafka.clients.producer.KafkaProducer.doSend(KafkaProducer.java:459)
at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:430)
at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:353)
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.