BAEL3889 - Adding braces in EvenOddPartitioner

This commit is contained in:
Chirag Dewan 2020-06-07 15:29:59 +05:30
parent e245b2eca3
commit de8acfd6e0
3 changed files with 7 additions and 4 deletions

View File

@ -1,4 +1,4 @@
package com.baeldung.kafka;
package com.baeldung.kafka.producer;
import org.apache.kafka.clients.producer.internals.DefaultPartitioner;
import org.apache.kafka.common.Cluster;
@ -8,8 +8,9 @@ public class EvenOddPartitioner extends DefaultPartitioner {
@Override
public int partition(String topic, Object key, byte[] keyBytes, Object value, byte[] valueBytes, Cluster cluster) {
if (((String)key).length() % 2 == 0)
if (((String) key).length() % 2 == 0) {
return 0;
}
return 1;
}

View File

@ -1,4 +1,4 @@
package com.baeldung.kafka;
package com.baeldung.kafka.producer;
import org.apache.kafka.clients.producer.Producer;
import org.apache.kafka.clients.producer.ProducerRecord;

View File

@ -1,5 +1,7 @@
package com.baeldung.kafka;
package com.baeldung.kafka.producer;
import com.baeldung.kafka.producer.EvenOddPartitioner;
import com.baeldung.kafka.producer.KafkaProducer;
import org.apache.kafka.clients.producer.MockProducer;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.apache.kafka.common.Cluster;