ian910297 commented on code in PR #16588:
URL: https://github.com/apache/kafka/pull/16588#discussion_r1677934043


##########
clients/src/test/java/org/apache/kafka/clients/consumer/ConsumerRecordsTest.java:
##########
@@ -145,6 +144,34 @@ public void testRecordsByTopic() {
         }
     }
 
+    @Test
+    public void testRecordsAreImmutable() {
+        String topic = "topic";
+        int recordSize = 3;
+        int partitionSize = 6;
+        int emptyPartitionIndex = 2;
+        TopicPartition topicFilter = new TopicPartition(topic, 0);
+        TopicPartition newPartition = new TopicPartition(topic, 0);
+        ConsumerRecord<Integer, String> newRecord = new 
ConsumerRecord<>(topic, 0, 0, 0L, TimestampType.CREATE_TIME,
+            0, 0, 0, "0", new RecordHeaders(), Optional.empty());
+        ConsumerRecords<Integer, String> records = 
buildTopicTestRecords(recordSize, partitionSize, emptyPartitionIndex, 
Collections.singleton(topic));
+        ConsumerRecords<Integer, String> emptyRecords = 
ConsumerRecords.empty();
+
+        // check records / partitions by add method
+        // check iterator by remove method
+        // check data count after all operations
+        assertThrows(UnsupportedOperationException.class, () -> 
records.records(topicFilter).add(newRecord));

Review Comment:
   Add assertion check for records(String).
   
   In addition to this, I checked the CustomerRecord class and confirmed all 
method in this class that return immutable objects are covered by our test scope



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