predatorray commented on a change in pull request #10525:
URL: https://github.com/apache/kafka/pull/10525#discussion_r800756743
##########
File path:
clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java
##########
@@ -1305,10 +1305,16 @@ private ClusterResourceListeners
configureClusterResourceListeners(Serializer<K>
*/
private int partition(ProducerRecord<K, V> record, byte[] serializedKey,
byte[] serializedValue, Cluster cluster) {
Integer partition = record.partition();
- return partition != null ?
- partition :
- partitioner.partition(
- record.topic(), record.key(), serializedKey,
record.value(), serializedValue, cluster);
+ if (partition != null) {
+ return partition;
+ }
+
+ int customPartition = partitioner.partition(
+ record.topic(), record.key(), serializedKey, record.value(),
serializedValue, cluster);
+ if (customPartition < 0) {
+ throw new IllegalArgumentException(String.format("Invalid
partition: %d. Partition number should always be non-negative.",
customPartition));
Review comment:
Sure. I have pushed a new commit. How about this one?
```java
"The partitioner generated an invalid partition number: %d. Partition number
should always be non-negative."
```
By the way, I think Jenkins PR check did not run quite well. The failed
tests are not related to this change. I tried some of these. Looks like they
could be passed on my laptop.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]