gaurav-narula commented on code in PR #24172:
URL: https://github.com/apache/kafka/pull/24172#discussion_r4641306387
##########
clients/src/test/java/org/apache/kafka/common/record/DefaultRecordTest.java:
##########
@@ -561,6 +561,32 @@ public void
testReadFromStreamRejectsBodySizeExceedingConfiguredMax() throws IOE
}
}
+ // A body size that fits in an array but exceeds the configured limit is a
policy violation by a well-formed
+ // record and is reported as RecordSizeLimitExceededException; a size
above the array-length ceiling can never
+ // belong to a real record and remains a plain InvalidRecordException
(corruption).
+ @Test
+ public void
testOnlyAllocatableBodySizeExceedingConfiguredMaxIsReportedAsLimitViolation()
throws IOException {
+ try (InputStream in = new
ByteBufferInputStream(ByteBuffer.wrap(recordWithForgedBodySize(1000)))) {
+ assertThrows(RecordSizeLimitExceededException.class,
+ () -> DefaultRecord.readFrom(in, 0L, 0L,
RecordBatch.NO_SEQUENCE, null, 100));
+ }
+ // readPartiallyFrom is not used in the down-conversion path
+ try (InputStream in = new
ByteBufferInputStream(ByteBuffer.wrap(recordWithForgedBodySize(1000)))) {
+ assertThrows(InvalidRecordException.class,
Review Comment:
Thanks! I've modified it to use `assertThrowsExactly` to disambiguate.
--
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]