chia7712 commented on code in PR #22514:
URL: https://github.com/apache/kafka/pull/22514#discussion_r3379515673
##########
clients/src/main/java/org/apache/kafka/common/serialization/ListDeserializer.java:
##########
@@ -220,14 +220,18 @@ private int readEntrySize(
final SerializationStrategy serStrategy,
final int length
) throws IOException {
- final int entrySize = serStrategy ==
SerializationStrategy.CONSTANT_SIZE ? primitiveSize : dis.readInt();
- if (entrySize < -1) { // value `-1` is valid, encoding a null entry
(-> ListSerde.NULL_ENTRY_VALUE)
- throw new SerializationException("Corrupted byte[]. A list entry
cannot have negative size.");
- }
- if (entrySize > length) {
- throw new SerializationException("Corrupted byte[]. A list entry
cannot be larger than the overall number of bytes.");
+ if (serStrategy == SerializationStrategy.CONSTANT_SIZE) {
Review Comment:
Is this just a refactor, or is there a functional change that I missed
:smiley:
##########
clients/src/main/java/org/apache/kafka/common/serialization/ListDeserializer.java:
##########
@@ -153,8 +153,8 @@ private List<Integer> deserializeNullIndexList(final
DataInputStream dis, final
if (nullIndexListSize < 0) {
throw new SerializationException("Corrupted byte[]. The number of
null list entries cannot be negative.");
}
- if (nullIndexListSize > length) {
- throw new SerializationException("Corrupted byte[]. The number of
null list entries cannot be larger than overall number of bytes.");
+ if (nullIndexListSize > length / primitiveSize) {
Review Comment:
Should we handle the null for the cases like
`shouldThrowOnTooLargeNullEntryLength`?
##########
clients/src/test/java/org/apache/kafka/common/serialization/ListDeserializerTest.java:
##########
@@ -380,14 +380,14 @@ public void shouldThrowOnTooLargeNullEntryLength() {
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xFF // encodes
number of null entries == 255
};
- final ListDeserializer<String> testDeserializer = new
ListDeserializer<>(ArrayList.class, new StringDeserializer());
+ final ListDeserializer<Integer> testDeserializer = new
ListDeserializer<>(ArrayList.class, new IntegerDeserializer());
Review Comment:
Should we update `shouldThrowOnNegativeNullEntryLength` for consistency?
--
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]