mjsax commented on code in PR #23158:
URL: https://github.com/apache/kafka/pull/23158#discussion_r3817345343
##########
streams/src/test/java/org/apache/kafka/streams/processor/internals/ProcessorRecordContextTest.java:
##########
@@ -110,4 +114,52 @@ public void shouldEstimateNullValueInHeaderAsZero() {
assertEquals(MIN_SIZE + 10L, context.residentMemorySizeEstimate());
}
+
+ @Test
+ public void shouldRejectHeaderCountLargerThanRemainingBuffer() {
+ final Headers headers = new RecordHeaders();
+ headers.add("header-key", "header-value".getBytes(UTF_8));
+ final ProcessorRecordContext context = new ProcessorRecordContext(
+ 42L, 73L, 0, "topic", headers);
+
+ final byte[] serialized = context.serialize();
+ final ByteBuffer buffer = ByteBuffer.wrap(serialized);
+
+ // Locate headerCount's position within the real serialized bytes
+ // timestamp(8) + offset(8) + topicLen(4) + "topic"(5) + partition(4)
+ final int headerCountOffset = 8 + 8 + 4 + "topic".getBytes().length +
4;
Review Comment:
```suggestion
final int headerCountOffset = 8 + 8 + 4 +
"topic".getBytes(UTF_8).length + 4;
```
--
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]