kamalcph commented on code in PR #15825: URL: https://github.com/apache/kafka/pull/15825#discussion_r1610399596
########## core/src/test/scala/unit/kafka/log/LogSegmentTest.scala: ########## @@ -143,6 +143,39 @@ class LogSegmentTest { checkEquals(ms2.records.iterator, read.records.records.iterator) } + @Test + def testReadWhenNoMaxPosition(): Unit = { + val maxPosition = -1 + val maxSize = 1 + val seg = createSegment(40) + val ms = records(50, "hello", "there") + seg.append(51, RecordBatch.NO_TIMESTAMP, -1L, ms) + for (minOneMessage <- Array(true, false)) { + // read before first offset + var read = seg.read(48, maxSize, maxPosition, minOneMessage) Review Comment: yes, when maxSize is negative (-1), then the following error will be thrown: ``` java.lang.IllegalArgumentException: Invalid max size -1 for log read from segment FileRecords(size=78, file=/var/folders/bq/w6tnkbq964q8sqpvj4fbmjr40000gq/T/kafka-18165220027855018994/00000000000000000040.log, start=0, end=2147483647) at org.apache.kafka.storage.internals.log.LogSegment.read(LogSegment.java:432) ``` -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org