m1a2st commented on code in PR #17063:
URL: https://github.com/apache/kafka/pull/17063#discussion_r1739649740


##########
clients/src/test/java/org/apache/kafka/clients/consumer/ConsumerRecordTest.java:
##########
@@ -98,4 +100,32 @@ record = new ConsumerRecord<>(topic, partition, offset, 
timestamp, timestampType
         assertEquals(deliveryCount, record.deliveryCount());
         assertEquals(headers, record.headers());
     }
+
+    @Test
+    public void testLeaderEpochChange() {
+        String topic = "topic";
+        int partition = 0;
+        long offset = 23;
+        long timestamp = 23434217432432L;
+        TimestampType timestampType = TimestampType.CREATE_TIME;
+        String key = "key";
+        String value = "value";
+        int serializedKeySize = 100;
+        int serializedValueSize = 1142;
+        Optional<Integer> leaderEpoch = Optional.of(1);
+
+        RecordHeaders headers = new RecordHeaders();
+        headers.add(new RecordHeader("header key", "header 
value".getBytes(StandardCharsets.UTF_8)));
+        ConsumerRecord<String, String> record = new ConsumerRecord<>(topic, 
partition, offset, timestamp, timestampType,
+                serializedKeySize, serializedValueSize, key, value, headers, 
leaderEpoch);
+
+        assertEquals(record.leaderEpoch(), leaderEpoch);
+        assertNotNull(record.leaderEpoch());

Review Comment:
   ditto



##########
clients/src/test/java/org/apache/kafka/clients/consumer/ConsumerRecordTest.java:
##########
@@ -49,6 +50,7 @@ public void testShortConstructor() {
         assertEquals(ConsumerRecord.NULL_SIZE, record.serializedValueSize());
         assertEquals(Optional.empty(), record.leaderEpoch());
         assertEquals(Optional.empty(), record.deliveryCount());
+        assertNotNull(record.leaderEpoch());

Review Comment:
   `leaderEpoch` is `Optional<Integer>`, I think the `assertNotnull` isn't a 
good assertion in here, and `record.leaderEpoch()` already check at line 51.



-- 
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]

Reply via email to